<template>
  <div class="page-container page-container-create">
    <div class="breadcrumb">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>营销中心</el-breadcrumb-item>
        <el-breadcrumb-item>通用促销</el-breadcrumb-item>
        <el-breadcrumb-item>创建秒杀活动</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <p class="font22 mb20" v-if="skillId && skillId != '0'">编辑秒杀活动</p>
    <p class="font22 mb20" v-else>创建秒杀活动</p>
    <div class="stepset" >
      <ul>
        <li :class="{'active':active>=1}"><span>1</span><p>设置活动规则</p></li>
        <!-- <li :class="{'active':active>=2}"><span>2</span><p>设置活动商家/店铺</p></li> -->
        <li :class="{'active':active>=2}"><span>2</span><p>设置活动商品</p></li>
        <li :class="{'active':active>=3}"><span>3</span><p>创建成功</p></li>
      </ul>
    </div>
    <div v-if="active == 1" class="content create_stepOne createSet create_stepAlso">
      <el-form
        :inline="true"
        :model="dataForm"
        :rules="dataFormRules"
        ref="dataForm"
        :label-position="labelPosition"
        label-width="140px"
      >
        <div class="w100">
          <div class="title">基本设置：</div>
          <div class="item">
            <el-row class="m_b30">
              <el-form-item label="活动名称：" prop="promName" class="wid">
                <el-input
                  size="mini"
                  type="text"
                  v-model.trim="dataForm.promName"
                  placeholder="请输入3-60个字符之间"
                  maxlength="60"
                  minlength="3"
                  clearable
                  class="input font14"
                />
              </el-form-item>
            </el-row>

            <el-row class="m_b30">
              <el-form-item label="活动时间：" prop="SeckillTime" class="wid w450">
                <el-date-picker
                  v-model="dataForm.SeckillTime"
                  type="datetimerange"
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  size="mini"
                  @change="SeckillTimeChanage"
                  :picker-options="timeCheck"
                ></el-date-picker>
              </el-form-item>
            </el-row>
     <el-row class="m_b30">
                <el-form-item label="活动搜索词：" prop="activitySearch" class="wid t_r" label-width="140px">
                  <el-input
                    type="text"
                    v-model.trim="dataForm.activitySearch"
                    placeholder="多个搜索词可用数据逗号“,”隔开"
                    class="input" clearable
                  />
                </el-form-item>
              </el-row>

               <el-row class="m_b30">
                <el-form-item label="活动费用预算：" prop="activityBudget" class="wid t_r" label-width="140px">
                  <el-input
                    type="text"
                    v-model.trim="dataForm.activityBudget"
                    placeholder="请输入平台营销费用"
                    class="input" clearable
                    oninput="value=value.replace(/[^\d]/g,'')"
                  /><span>元</span>
                </el-form-item>
              </el-row>
              <el-row class="m_b30">
                <el-form-item label="预警比例：" prop="warningProportion" class="wid t_r" label-width="140px">
                  <el-input
                    type="text"
                    v-model.trim="dataForm.warningProportion"
                    placeholder="请输入预警比例："
                    class="input" clearable
                    oninput="value=value.replace(/[^\d]/g,'')"
                  /><span>%</span>
                </el-form-item>
              </el-row>
            <!-- <el-row class="m_b60 activityTags">
              <el-form-item label="活动标签：" prop="tags" class="wid">
                <el-select v-model="dataForm.label" placeholder="请选择" size="mini" clearable class="width450">
                  <el-option
                    v-for="item in tagsList"
                    :key="item.id"
                    :label="item.tagName"
                    :value="item.id"
                  ></el-option>
                </el-select>
                <el-button type="primary" @click="addtags" size="mini" class="searchButton">添加标签</el-button>
              </el-form-item>
            </el-row> -->
          </div>

          <div class="w100">
            <div class="title">活动规则：</div>
            <div class="item">
              <el-row class="mb30 timeStage">
                <el-form-item label="每日时间段：" prop="startTimeEveryDay" class="wid etAlignment everyDate">
                <el-time-select
                  class="m_r16 stepOne_table mb20"
                  placeholder="开始时间"
                  size="mini"
                  v-model="dataForm.startTimeEveryDay"
                  @change="change"
                  :picker-options="{
                                    start: '00:00',
                                    step: '01:00',
                                    end: '24:00'}"
                ></el-time-select>
                <el-time-select

                  placeholder="结束时间"
                  size="mini"
                  v-model="dataForm.endTimeEveryDay"
                  :picker-options="{
                                    start: '00:00',
                                    step: '01:00',
                                    end: '24:00',
                                    minTime: dataForm.startTimeEveryDay,
                                    maxTime: dataForm.TimeEveryDay.length < 1  ?  maxTime  : formatTimeEveryDay(dataForm.TimeEveryDay[0].startTimeOfDate)}"
                ></el-time-select>
                <el-button
                  type="primary"
                  @click="addTimeEveryDay"
                  size="mini"
                  class="searchButton"
                  :disabled="addTimeEveryDayBtnStatus"
                >新增</el-button>

                <div v-for="(item, index) in dataForm.TimeEveryDay" :key="index" class="mb20 b:last-child{
                  margin-bottom:0 !important
                  }oxes">
                  <el-time-select
                    class="m_r16 "
                    placeholder="起始时间"
                    size="mini"
                    v-model="dataForm.TimeEveryDay[index].startTimeOfDate"
                    :picker-options="{
                                        start: '00:00',
                                        step: '01:00',
                                        end: '24:00',
                                        minTime: index == 0 ? formatTimeEveryDay(dataForm.endTimeEveryDay) : formatTimeEveryDay(dataForm.TimeEveryDay[index-1].endTimeOfDate)
                                        }"
                  ></el-time-select>
                  <el-time-select
                    placeholder="结束时间"
                    size="mini"
                    v-model="dataForm.TimeEveryDay[index].endTimeOfDate"
                    :picker-options="{
                                        start: '00:00',
                                        step: '01:00',
                                        end: '24:00',
                                        minTime: dataForm.TimeEveryDay[index].startTimeOfDate,
                                        maxTime: index == (dataForm.TimeEveryDay.length - 1)  ? maxTime  : formatTimeEveryDay(dataForm.TimeEveryDay[index+1].startTimeOfDate)
                                        }"
                  ></el-time-select>
                  <el-button  @click="deleteTimeEveryDay(index)" size="mini" class="resetButton">删除</el-button>
                </div>
                </el-form-item>
              </el-row>
              <el-row class="mb10">
                <el-form-item label="预热时间：" class="wid">
                <!-- <div class="timePreheat"> -->
                <el-input
                  v-model="dataForm.warmUpTime"
                  auto-complete="off"
                  type="text"
                  :size="size"
                  style="width:90%"
                  oninput="value=value.replace(/[^\d]/g,'')"
                  clearable
                ></el-input>
                <!-- </div> -->
                </el-form-item>
                  <span class="s1">小时</span>
              </el-row>
              <el-row class="timeStageDesc m_b30">
                <el-form-item label class="wid">
                  <div class="desc color666">活动开始前会在商品详情页展示活动信息</div>
                </el-form-item>
              </el-row>
           <el-row class="m_b30">
                <el-form-item label="活动图片：" class="wid">
                  <div class="img-border">
                    <div
                      tabindex="0"
                      class="el-upload el-upload--picture-card img-card-upload"
                      @click="selectUploadMethod"
                    >
                      <i data-v-5410c7af class="el-icon-plus"></i>
                    </div>
                    <div
                      class="img-card"
                      v-for="(item, index) in imgUrlList"
                      :key="index"
                      @mouseleave="mouseLeave(index)"
                      @mouseenter="mouseEnter(index)"
                    >
                      <el-image :src="item.url" style="width: 100%;height: 100%;" />
                      <span
                        class="el-upload-list-item-actions"
                        :class="imgUrlList[index].hover != null ? 'el-upload-list-item-actions-hover' : '' "
                      >
                        <span
                          class="el-upload-list__item-preview upload-delete"
                          @click="deleteimgUrlList(index)"
                        >
                          <i class="el-icon-delete deleteButton"></i>
                        </span>
                      </span>
                    </div>


                  </div>
                </el-form-item>
              </el-row>
              <!-- <el-row class="labelAlignment m_b60">
                <el-form-item label="活动描述：" class="wid vt">
                <el-input
                  class="activityDesc"
                  type="textarea"
                  :rows="2"
                  placeholder="最多输入100个字"
                  v-model="dataForm.description"

                  maxlength="100"
                  clearable
                ></el-input>
                </el-form-item>
                <el-form-item label class="wid">
                  <div
                    class="desc color666"
                  >注：非必填字段，不填将显示系统默认文案（会存在某些促销类型无系统默认文案）。自定义输入活动规则描述描述后将显示在前台商品详情页中，请慎重填写。</div>
                </el-form-item>
              </el-row> -->
            </div>
          </div>

          <div class="w100">
            <div class="title">交易规则：</div>
            <div class="item">
              <!-- <el-row class="m_b30 labelAlignment">
                <el-form-item label="是否包邮：" class="wid">
                  <el-radio-group v-model="dataForm.parcelsFlag">
                    <el-radio class="form-radio mr40 radioAlignment w144 t_l noMarginLeft" border label="1" value="1">是</el-radio>
                    <el-radio class="form-radio radioAlignment w144 t_l noMarginLeft" border label="0" value="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
              </el-row> -->

              <el-row class="labelAlignment mb30">
                <el-form-item label="超限规则：" class="wid">
                  <el-radio-group v-model="dataForm.overLimitRule">
                    <el-radio
                      class="form-radio mr40 radioAlignment noMarginLeft"
                      label="1"
                      value="0"
                      border
                    >按原价购买</el-radio>
                    <el-radio
                      class="form-radio radioAlignment noMarginLeft mr10"
                      label="2"
                      value="1"
                      border
                    >不可以购买</el-radio>
                  </el-radio-group>
                  <el-tooltip  effect="dark" content="注：超限规则指用户购买商品数量超过活动可购买数量" placement="right">
                    <span class="tipsInfo">!</span>
                  </el-tooltip>
                </el-form-item>
              </el-row>
              <!-- <el-row class="timeStageDesc m_b30">
                <el-form-item label class="wid">
                  <div class="desc color666"></div>
                </el-form-item>
              </el-row> -->
              <el-row class="m_b60 ways labelAlignment">
                <el-form-item label="是否分摊：" prop="costAllocationFlag" class="wid">
                <el-row class="m_b30">
                  <el-radio-group v-model="dataForm.costAllocationFlag" prop="costAllocationFlag">
                    <el-radio
                      v-model="dataForm.costAllocationFlag"
                      label="1"
                      checked="true"
                      name="type"
                      value="1"
                      class="form-radio mr40 radioAlignment w144 t_l noMarginLeft"
                      border
                    >是</el-radio>
                    <el-radio
                      v-model="dataForm.costAllocationFlag"
                      label="2"
                      name="type"
                      value="2"
                      class="form-radio radioAlignment w144 t_l noMarginLeft"
                      border
                    >否</el-radio>
                  </el-radio-group>
                </el-row>

<!--                 <div class="rates" v-if="dataForm.costAllocationFlag == '1'">-->
<!--                  <template v-if="dataForm.costAllocationFlag == '1'">-->
<!--                    <span>运营平台比例：</span>-->
<!--                    <el-form-item prop="parentAllocationScale">-->
<!--                      <el-input-->
<!--                        v-model.trim="dataForm.parentAllocationScale"-->
<!--                        oninput="value=value.replace(/[^\d]/g,'')"-->
<!--                        auto-complete="off"-->
<!--                        type="text"-->
<!--                        :size="size"-->
<!--                        class="parentPlatformRatio"-->
<!--                        clearable-->
<!--                      ></el-input>-->
<!--                    </el-form-item>-->
<!--                    <span class="m_r16">%</span>-->
<!--                  </template>-->
<!--                  <template-->
<!--                    v-if="dataForm.costAllocationFlag == '1'"-->
<!--                  >-->
<!--                    <span>运营子平台比例：</span>-->
<!--                    <el-form-item prop="childAllocationScale">-->
<!--                      <el-input-->
<!--                        v-model.trim="dataForm.childAllocationScale"-->
<!--                        oninput="value=value.replace(/[^\d]/g,'')"-->
<!--                        auto-complete="off"-->
<!--                        type="text"-->
<!--                        :size="size"-->
<!--                        class="parentPlatformRatio"-->
<!--                        clearable-->
<!--                      ></el-input>-->
<!--                    </el-form-item>-->
<!--                    <span class="m_r16">%</span>-->
<!--                  </template>-->
<!--                  <template-->
<!--                    v-if="dataForm.costAllocationFlag == '1'"-->
<!--                  >-->
<!--                    <span>商家比例：</span>-->
<!--                    <el-form-item prop="merchantAllocationScale">-->
<!--                      <el-input-->
<!--                        v-model.trim="dataForm.merchantAllocationScale"-->
<!--                        oninput="value=value.replace(/[^\d]/g,'')"-->
<!--                        auto-complete="off"-->
<!--                        type="text"-->
<!--                        :size="size"-->
<!--                        class="parentPlatformRatio"-->
<!--                        clearable-->
<!--                      ></el-input>-->
<!--                    </el-form-item>-->
<!--                    <span class="m_r16">%</span>-->
<!--                  </template>-->
<!--                  <template-->
<!--                    v-if="dataForm.costAllocationFlag == '1'"-->
<!--                  >-->
<!--                    <span>店铺比例：</span>-->
<!--                    <el-form-item prop="storeAllocationScale">-->
<!--                      <el-input-->
<!--                        v-model.trim="dataForm.storeAllocationScale"-->
<!--                        oninput="value=value.replace(/[^\d]/g,'')"-->
<!--                        auto-complete="off"-->
<!--                        type="text"-->
<!--                        :size="size"-->
<!--                        class="parentPlatformRatio"-->
<!--                        clearable-->
<!--                      ></el-input>-->
<!--                    </el-form-item>-->
<!--                    <span>%</span>-->
<!--                  </template>-->
<!--                </div>-->
                </el-form-item>
              </el-row>
            </div>
          </div>

          <div class="w100">
            <div class="title">参与条件：</div>
            <div class="item">

               <!--<el-row class="m_b30 ways labelAlignment" v-if="deptType == 0">
                <el-form-item label="使用渠道：" prop="channelIds" class="wid">
                  <el-tree
                    :data="channelList"
                    :default-checked-keys="defaultCheckedKeys"
                    @check="channelCheckChange"
                    :props="channlProps"
                    show-checkbox
                    node-key="id"
                    :default-expand-all="true"
                    ref="channelTree"
                  ></el-tree>
                </el-form-item>
              </el-row>-->

              <el-row class="m_b30 labelAlignment">
                <!-- <el-form-item label="新老用户：" prop="proUserType" class="wid">
                  <div style="width:100%;">
                    <el-radio
                      class="m_r45 radioAlignment"
                      v-model="dataForm.proUserType"
                      label="0"
                      value="0"
                    >全部</el-radio>
                    <el-radio
                      class="m_r45 radioAlignment"
                      v-model="dataForm.proUserType"
                      label="2"
                      value="2"
                    >老用户</el-radio>
                    <el-radio
                      class="radioAlignment"
                      v-model="dataForm.proUserType"
                      label="1"
                      value="1"
                    >新用户</el-radio>
                  </div>
                </el-form-item> -->
                <el-form-item label="新老用户：" prop="selectUserType" class="wid t_r" label-width="140px">
                  <div class="flex">
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w144 t_l mleft10" border :indeterminate="userTypeIsIndeterminate" v-model="userTypeCheckAll" @change="handleCheckAllUserTypeChange">全选</el-checkbox>
                    <el-checkbox-group v-model="selectUserType" @change="handleCheckedUserTypeChange">
                      <el-checkbox :label="1" :key="1" class="mr40 el-checkBox-padding noMarginLeft w144 t_l" border>新用户</el-checkbox>
                      <el-checkbox :label="2" :key="2" class="el-checkBox-padding noMarginLeft w144 t_l" border>老用户</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </el-form-item>
              </el-row>

               <el-row class="m_b52 labelAlignment">
                <el-form-item label="会员类型：" prop="selectMemTypes" class="wid t_r" label-width="140px">
                    <div class="flex">
                      <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w144 t_l mleft10" border :indeterminate="memTypeIsIndeterminate" v-model="memTypeCheckAll" @change="handleCheckAllMemTypeChange">全选</el-checkbox>
                      <el-checkbox-group v-model="selectMemTypes" @change="handleCheckedMemTypeChange">
                        <el-checkbox :label="1" :key="1" class="mr40 el-checkBox-padding noMarginLeft w144 t_l" border>普通会员</el-checkbox>
                          <el-checkbox :label="2" :key="2" border class="el-checkBox-padding noMarginLeft">we2000</el-checkbox>
                      <el-checkbox :label="3" :key="3" border class="el-checkBox-padding noMarginLeft">分期会员</el-checkbox>
                    </el-checkbox-group>
                    </div>
                </el-form-item>
              </el-row>
              <el-row class="m_b52 labelAlignment">
                <el-form-item label="渠道入口：" prop="channelId" class="wid t_r" label-width="140px">
                  <div class="flex">
                    <el-checkbox class="mr40 el-checkBox-padding noMarginLeft w130 t_l mleft10" border :indeterminate="memTypeIsIndeterminate" v-model="memTypeCheckAll" @change="handleCheckAllMemTypeChange">全选</el-checkbox>
                    <el-checkbox-group v-model="selectMemTypes" @change="handleCheckedMemTypeChange">
                      <el-checkbox :label="1" :key="1" border class="mr40 el-checkBox-padding noMarginLeft">企业微信</el-checkbox>
                      <el-checkbox :label="2" :key="2" border class="mr40 el-checkBox-padding noMarginLeft">xxx</el-checkbox>
                      <el-checkbox :label="3" :key="3" border class="mr40 el-checkBox-padding noMarginLeft">yyy</el-checkbox>
                    </el-checkbox-group>
                  </div>
                </el-form-item>
              </el-row>

              <el-row>
                <el-form-item label="备注：" class="wid t_r" label-width="140px">
                  <el-input
                    type="textarea"
                    v-model="dataForm.remark"
                    @input="changeRemark($event)"
                    placeholder="请输入备注"
                    class="remarks h286"
                    clearable
                  ></el-input>
                </el-form-item>
              </el-row>
            </div>
          </div>
        </div>
      </el-form>
    </div>
    <!-- <div v-if="active == 2" class="tab-container tab-container-noPadding createSet">
      <el-tabs v-model="activeName" type="border-card">
        <el-tab-pane label="商家" name="1">
          <el-row class="search-button-fix t_r" size="small">
            <div>
              <el-button class="searchButton" @click="showSeachMerchant = !showSeachMerchant" icon="el-icon-search">搜索</el-button>
              <el-button class="searchButton" @click="addMerchant">添加商家</el-button>
              <el-button class="resetButton" @click="batchDeleteMerchant">批量删除</el-button>
            </div>
          </el-row>
          <div v-if="showSeachMerchant" class="f_r mb30">
              <el-form
                :inline="true"
                :model="merchantStaticDataForm"
                size="mini"
                ref="merchantStaticDataForm"
                :rules="merchantStaticDataFormRules"
              >
                <el-form-item label="商家编码：" prop="orgNumber" class="mr30">
                  <el-input v-model="merchantStaticDataForm.orgNumber" placeholder="商家编码" clearable maxlength="80"></el-input>
                </el-form-item>
                <el-form-item label="商家名称：" prop="merchantName">
                  <el-input v-model="merchantStaticDataForm.merchantName" placeholder="商家名称" clearable maxlength="80"></el-input>
                </el-form-item>
                <el-form-item label prop="mpName">
                  <el-button
                    class="resetButton"
                    size="mini"
                    @click="resetMerchantSearch()"
                  >重置</el-button>
                  <el-button class="resetButton" size="mini" @click="merchantSearch()">查询</el-button>

                </el-form-item>
              </el-form>
            </div>
          <div class="table-section">
            <el-table
              :data="tableData"
              :header-cell-style="tableHeaderColor"
              ref="multipleTable"
              :row-class-name="tableRowClassName"
              :size="size"
              @selection-change="selectMerchantChange"
            >
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column v-if="false" prop="merchantId"></el-table-column>
              <el-table-column prop="orgNumber" label="商家编码" sortable align="center"></el-table-column>
              <el-table-column prop="name" label="商家名称" align="center"></el-table-column>
              <el-table-column prop="merchantType" label="商家类型" align="center">
                <template slot-scope="scope">
                  <span v-if="scope.row.merchantType == '1'">自营商家</span>
                  <span v-else-if="scope.row.merchantType == '2'">第三方商家</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" fixed="right" align="center">
                <template slot-scope="scope">
                  <el-button
                    :size="size"
                    type="text"
                    @click="handleDelete(scope.$index, scope.row)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div v-if="tableData.length > 0" class="t_r">
            <el-pagination
              @size-change="merchantSizeChange"
              @current-change="merchantCurrentChange"
              :current-page="merchantStaticDataForm.start"
              :page-sizes="[10]"
              :page-size="merchantStaticDataForm.limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="merchantTotal"
            ></el-pagination>
          </div>
        </el-tab-pane>
        <el-tab-pane label="店铺" name="2">
          <el-row class="search-button-fix t_r" size="small">
            <div>
              <el-button class="searchButton" @click="showSeachStore = !showSeachStore" icon="el-icon-search">搜索</el-button>
              <el-button class="searchButton" @click="addStore">添加店铺</el-button>
              <el-button class="resetButton" @click="batchDeleteStore">批量删除</el-button>
            </div>
          </el-row>
          <div v-if="showSeachStore" class="f_r mb30">
              <el-form
                :inline="true"
                :model="storeStaticDataForm"
                size="mini"
                ref="storeStaticDataForm"
                :rules="storeStaticDataFormRules"
              >
                <el-form-item label="店铺编码：" prop="storeCode" class="mr30">
                  <el-input v-model="storeStaticDataForm.storeCode" placeholder="店铺编码" clearable maxlength="80"></el-input>
                </el-form-item>
                <el-form-item label="店铺名称：" prop="storeName">
                  <el-input v-model="storeStaticDataForm.storeName" placeholder="店铺名称" clearable maxlength="80"></el-input>
                </el-form-item>
                <el-form-item label prop="mpName">
                  <el-button
                    class="resetButton"
                    size="mini"
                    @click="resetstoreSearch"
                  >重置</el-button>
                  <el-button class="resetButton" size="mini" @click="storeSearch">查询</el-button>

                </el-form-item>
              </el-form>
            </div>
          <div>
            <el-table
              :data="storeTableData"
              :header-cell-style="tableHeaderColor"
              ref="multipleTable"
              :row-class-name="tableRowClassName"
              :size="size"
              @selection-change="selectStoreChange"
            >
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column v-if="false" prop="storeId">
                <template slot-scope="scope">
                  <div :model="scope.row.id"></div>
                </template>
              </el-table-column>
              <el-table-column prop="storeCode" label="店铺编码" sortable align="center"></el-table-column>
              <el-table-column prop="storeName" label="店铺名称" align="center"></el-table-column>
               <el-table-column label="店铺类型" align="center">
                <template slot-scope="scope">
                    　{{scope.row.storeType == '0' ? '自营店铺' : '入驻店铺'}}
                  </template>
              </el-table-column>
              <el-table-column prop="merchantName" label="所属商家" align="center"></el-table-column>
              <el-table-column label="操作" fixed="right" align="center">
                <template slot-scope="scope">
                  <el-button
                    :size="size"
                    type="text"
                    @click="handleDeleteStore(scope.$index, scope.row)"
                  >删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div v-if="storeTableData.length > 0" class="t_r">
            <el-pagination
              @size-change="storeSizeChange"
              @current-change="storeCurrentChange"
              :current-page="storeStaticDataForm.start"
              :page-sizes="[10]"
              :page-size="storeStaticDataForm.limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="storeTotal"
            ></el-pagination>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div> -->
    <div v-if="active == 2" class="tab-container createSet active3">
      <div>
        <el-tabs v-model="timeOfDateId" type="card" @tab-click="handleTitleClick">
          <el-tab-pane
            :label="item.showTimeOfDate"
            :name="item.skillTimeId"
            v-for="(item, index) in periodList"
            :key="index"
          ></el-tab-pane>
        </el-tabs>
      </div>
      <el-tabs type="border-card" v-model="activeTab"  @tab-click="productTabs">
        <div class="row-line-button" style="text-align: right;">
          <div style="width:100%">
            <el-button
              class="searchButton"
              size="mini"
              v-show="showButtons"
              @click="searchGoodsFlag = !searchGoodsFlag"
              icon="el-icon-search"
            >搜索</el-button>
            <!-- <el-button type="primary" v-show="false" @click="saveAllGoods">添加全部商品</el-button> -->
            <el-button class="searchButton" v-show="showButtons" @click="add">添加促销商品</el-button>
            <el-button class="resetButton" v-show="showButtons" @click="batchDeleteProduct">批量删除</el-button>
            <!-- <el-button class="resetButton" v-show="!showButtons" @click="batchRenewAdd">批量重新添加</el-button> -->
          </div>
        </div>
        <el-row v-if="searchGoodsFlag" class="f_r">
          <el-form :inline="true" :model="queryGoodsReuqest" ref="queryGoodsReuqest" class="rightForm demo-form-inline2" size="small">

              <el-form-item label="商户：" prop="storeId" class="mb30">
                <template>
                  <el-select v-model="queryGoodsReuqest.storeId" clearable placeholder="全部">
                    <el-option
                      v-for="item in storeTableData"
                      :key="item.id"
                      :label="item.storeName"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </template>
              </el-form-item>

              <el-form-item label="商品编码：" prop="goodsCode" class="mb30">
                <el-input v-model="queryGoodsReuqest.goodsCode" clearable placeholder="商品编码" maxlength="80"></el-input>
              </el-form-item>
              <el-form-item label="商品名称：" prop="goodsName" class="mb30">
                <el-input v-model="queryGoodsReuqest.goodsName" clearable placeholder="商品名称" maxlength="80"></el-input>
              </el-form-item>
              <el-form-item label="商品分类：" prop="goodsType" class="mb30">
                <el-input v-model="queryGoodsReuqest.goodsType" clearable placeholder="商品类目" maxlength="80"></el-input>
              </el-form-item>
              <el-form-item label >
                <el-button
                  class="resetButton"
                  size="mini"
                  @click="resetStaticGoodsSearch()"
                >重置</el-button>
                <el-button class="resetButton" size="mini" @click="skillQueryGoods()">查询</el-button>

              </el-form-item>
            <!-- <el-form-item>
              <el-button
                type="primary"
                size="mini"
                @click="searchGoodsFlag = !searchGoodsFlag"
                icon="el-icon-search"
              >搜索</el-button>
            </el-form-item> -->
          </el-form>
      </el-row>
        <el-tab-pane :label="noMutexProductLabel" name="noMutexProduct">
          <div class="tableTree" >

            <el-table
              :data="productTableData"
              :header-cell-style="tableHeaderColor"
              ref="multipleTable"
              :row-class-name="tableRowClassName"
              default-expand-all
              row-key="goodsId"
              :size="size"
              :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
              @selection-change="selectPorduct"
              class="tableStyle"
            >
              <el-table-column align="left" width="30">
                <template slot="header" slot-scope="scope">
                  <div class="isAllChecked" v-show="allProductData.length > 0">
                    <el-checkbox
                      :indeterminate="isIndeterminateProductCheck"
                      v-model="isAllProductChecked"
                      @change="handleCheckedAllProductChange"
                    ></el-checkbox>
                  </div>
                </template>
              </el-table-column>
              <el-table-column width="40">
                <template slot-scope="scope">
                  <el-checkbox
                    :indeterminate="scope.row.isIndeterminateCheck"
                    v-model="scope.row.isCheck"
                    @change="handleCheckedProductChange(scope.row,$event)"
                  ></el-checkbox>
                </template>
              </el-table-column>
              <el-table-column prop="goodsCode" label="商品编码" sortable align="left" width="200"></el-table-column>
              <el-table-column prop="goodsName" label="商品名称" align="center" width="200"></el-table-column>
              <!-- <el-table-column prop="merchantName" label="商家名称" align="center"></el-table-column> -->
              <el-table-column prop="goodsTypeName" label="商品分类" align="center" width="200"></el-table-column>
              <el-table-column prop="reserveNum" label="库存" align="center" ></el-table-column>
              <el-table-column prop="storeName" label="所属商户" align="center" width="200"></el-table-column>
              <el-table-column prop="storeName" label="商户code" align="center" width="200"></el-table-column>
              <el-table-column prop="goodsPrice" label="零售价（元）" align="center" width="200"></el-table-column>

              <el-table-column label="*秒杀价" align="center" width="200">
                <template slot-scope="scope">
                  <el-input
                    type="text"
                    v-model="scope.row.skillPrice"
                    @blur="updateSkillPrice(scope.row)"
                    style="width:120px;"
                    placeholder="秒杀价"
                    :size="size"
                    clearable maxlength="10"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column prop="deptShare" label="平台分摊" align="center" width="200" v-if="dataForm.costAllocationFlag=='1'">
                <template slot-scope="scope">
                  <el-input
                    type="text"
                    v-model.number="scope.row.deptShare"
                    @blur="updateSkillPrice(scope.row)"
                    placeholder="平台分摊"
                    style="width:120px;"
                    :size="size"
                    clearable maxlength="10"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column prop="merchantShare" label="商户分摊" align="center" width="200" v-if="dataForm.costAllocationFlag=='1'">
                <template slot-scope="scope">
                  <el-input
                    type="text"
                    v-model.number="scope.row.merchantShare"
                    @blur="updateSkillPrice(scope.row)"
                    placeholder="商户分摊"
                    style="width:120px;"
                    :size="size"
                    clearable maxlength="10"
                  >%</el-input>
                </template>
              </el-table-column>
               <el-table-column prop="reserveNum" label="活动库存" align="center" ></el-table-column>
              <el-table-column label="个人限购" align="center" width="200">
                <template slot-scope="scope">
                  <el-input
                    type="text"
                    v-model.number="scope.row.userChannelLimit"
                    @blur="updateSkillPrice(scope.row)"
                    placeholder="个人限购"
                    style="width:120px;"
                    :size="size"
                    clearable maxlength="10"
                  ></el-input>
                </template>
              </el-table-column>
                <el-table-column label="订单限购" align="center" width="200">
                <template slot-scope="scope">
                  <el-input
                    type="text"
                    v-model.number="scope.row.storeChannelLimit"
                    @blur="updateSkillPrice(scope.row)"
                    placeholder="订单限购"
                    style="width:120px;"
                    :size="size"
                    clearable maxlength="10"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column label="操作" fixed="right" align="center" width="200">
                <template slot-scope="scope">
                  <el-button
                    :size="size"
                    type="text"
                    @click="deleteProduct(scope.$index, scope.row)"
                  >删除</el-button>
                </template>
                 <el-button
                        icon="el-icon-document"
                        size="mini"
                        class="searchButton"
                        @click="downloadTemplate"
                        v-if="true"
                      >模板下载</el-button>
                      <el-upload
                        class="avatar-uploader"
                        :show-file-list="true"
                        accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
                        v-if="true"
                      >
                        <el-button
                          icon="el-icon-document-add"
                          size="mini"
                          class="searchButton"
                          v-if="true"
                        >商品导入</el-button>
                      </el-upload>
              </el-table-column>


            </el-table>
            <div v-if="productTableData.length > 0" class="t_r">
              <el-pagination
                @size-change="goodsSizeChange"
                @current-change="goodsCurrentChange"
                :current-page="goodsStaticDataForm.start"
                :page-sizes="[10]"
                :page-size="goodsStaticDataForm.limit"
                layout="total, sizes, prev, pager, next, jumper"
                :total="goodsTotal"
              ></el-pagination>
            </div>
          </div>

        </el-tab-pane>
        <el-tab-pane :label="mutexProductLabel" name="mutexProduct">
          <div class="tableTree" style="margin-top: 50px;">

            <el-table :data="mutexProductList"  row-key="id" default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
              @selection-change="batchRenewAddSelectionChange" style="width: 100%" class="tableStyle">
              <el-table-column align="left" width="30">
                <template slot="header" slot-scope="scope">
                  <div class="isAllChecked"  v-show="allData.length > 0">
                    <el-checkbox
                      :indeterminate="isIndeterminateCheck"
                      v-model="isAllChecked"
                      @change="handleCheckedAllChange"
                    ></el-checkbox>
                  </div>
                </template>
              </el-table-column>
              <el-table-column width="40">
                <template slot-scope="scope">
                  <el-checkbox
                    :indeterminate="scope.row.isIndeterminateCheck"
                    v-model="scope.row.isCheck"
                    @change="handleCheckedChange(scope.row,$event)"
                  ></el-checkbox>
                </template>
              </el-table-column>
              <el-table-column prop="goodsCode" label="商品编码" width="200"  align="left"></el-table-column>
              <el-table-column prop="goodsName" label="商品名称" width="200"></el-table-column>
              <el-table-column prop="goodsTypeName" label="商品分类" width="200"></el-table-column>
              <el-table-column prop="reserveNum" label="库存" width="200"></el-table-column>
              <el-table-column prop="goodsPrice" label="原价（元）" width="200"></el-table-column>
              <el-table-column prop="storeName" label="所属商户" width="200"></el-table-column>
              <el-table-column prop="storeName" label="商户code" width="200"></el-table-column>
              <el-table-column align="center" fixed="right" label="操作" width="390">
                <template slot-scope="scope">
                  <el-button @click="getMutexInfo(scope.row)" v-if="scope.row.typeOfProduct==20" type="text" class="textButton" size="small">查看详情</el-button>
                  <el-button @click="renewAdd(scope.row)" v-if="scope.row.typeOfProduct==10 || scope.row.typeOfProduct==20" type="text" class="textButton" size="small">重新添加</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="toolbar t_r" >
              <el-pagination
                @size-change="handleSizeChangeMutexProductList"
                @current-change="handleCurrentChangeMutexProductList"
                :current-page="mutexProductForm.start"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="mutexProductForm.limit"
                layout="total, sizes, prev, pager, next, jumper"
                :total="mutexProductTotal"
              >
              </el-pagination>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div v-if="active == 3" class="tab-container tab-success createSet">
      <div class="titleInfo">
        <img src="/static/images/success.png" />
        <span class="font20">活动创建成功!</span>
      </div>
      <div class="step-button2">
        <el-button class="resetButton" @click="viewList">查看秒杀列表</el-button>
        <template>
          <kt-button
            class="searchButton"
            :size="size"
            @click="shenheHuodong(0)"
            v-if="[11,14,9].includes(dataForm.status)"
            label="提交审核"
          />
         <kt-button
           class="searchButton"
           :size="size"
           @click="shenheHuodong(1)"
           v-if="[12].includes(dataForm.status)"
           label="审核"
         />
        </template>
        <!-- <kt-button
          class="resetButton"

          :size="size"
          @click="templateDialogFormVisible = true"
          perms="market:seckill:addtemp"
          label="保存模板"
        /> -->
      </div>
    </div>
    <div class="step-button" v-if="active < 3">
      <el-button
        class="cancelButton"
        :plain="active != 1 && active != 4"
        :size="size"
        v-if="active != 1 && active != 4"
        @click="back"
      >上一步</el-button>
      <el-button type="primary" v-if="active != 4" :size="size" @click="next" class="searchButton">下一步</el-button>
    </div>
    <!-- 模板弹窗 -->
    <el-dialog title="保存模板" class="el-dialog-style" :visible.sync="templateDialogFormVisible" :close-on-click-modal="false">
      <el-form :model="templateForm" label-width="130px">
        <el-form-item label="模板名称：">
          <el-input v-model="templateForm.templateName" autocomplete="off" size="mini" clearable placeholder="输入模板名称"  maxlength="60"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" plain @click="templateDialogFormVisible=false" size="mini" class="cancelButton">取消</el-button>
        <el-button type="primary" @click="saveTemplate()" size="mini" class="searchButton">保存模板</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt />
    </el-dialog>


    <!-- 互斥活动详情 -->
    <el-dialog :visible.sync="mutexPromotionVisible" title="互斥活动详情" width="70%" :close-on-click-modal="false">
      <div>
        <el-table :data="mutexPromotionList" ref="multipleTable" :row-class-name="tableRowClassName"  :size="size">
          <el-table-column prop="promotionCode" width="280" label="互斥活动编码" sortable align="center"></el-table-column>
          <el-table-column prop="promName"  width="150" label="互斥活动名称" align="center">
            <template slot-scope="scope">
              <el-button @click="linkInfoByMutexProduct(scope.row.promotionId,scope.row.promType)" type="text" class="textButton" size="small">{{scope.row.promName}}</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="goodsCategory"  width="350" label="互斥活动时间" align="center">
            <template slot-scope="scope">
                <span>{{scope.row.startTime}} - {{scope.row.endTime}}</span>
              </template>
          </el-table-column>
          <el-table-column prop="storeName" label="活动状态" align="center">
            <template slot-scope="scope">
              <span class="color333 font18" v-if="scope.row.status == 0">待提交</span>
              <span class="color333 font18" v-else-if="scope.row.status == 1">待提交</span>
              <span class="color333 font18" v-else-if="scope.row.status == 2">待审核</span>
              <span class="color333 font18" v-else-if="scope.row.status == 3">未开始</span>
              <span class="color333 font18" v-else-if="scope.row.status == 4">审核不通过</span>
              <span class="color333 font18" v-else-if="scope.row.status == 5">进行中</span>
              <span class="color333 font18" v-else-if="scope.row.status == 6">已过期</span>
              <span class="color333 font18" v-else-if="scope.row.status == 7">已关闭</span>
              <span class="color333 font18" v-else-if="scope.row.status == 8">已结束</span>
              <span class="color333 font18" v-else-if="scope.row.status == 9">活动草稿</span>
            </template>
          </el-table-column>
          <el-table-column prop="creatorName" label="创建人" align="center"></el-table-column>
          <el-table-column prop="deptName"  label="创建组织" align="center"></el-table-column>
        </el-table>
        <!--分页栏-->
        <div class="toolbar t_r">
          <el-pagination
            @size-change="mutexPromotionListSizeChange"
            @current-change="mutexPromotionListCurrentChange"
            :current-page="mutexPromotionForm.start"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="mutexPromotionForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="mutexPromotionListTotal"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer t_c">
        <el-button type="primary" plain :size="size" @click.native="mutexPromotionVisible = false" class="searchButton">关闭</el-button>
      </div>
    </el-dialog>


    <el-dialog :visible.sync="dialogVisibleMerchant" title="添加商家" :close-on-click-modal="false">
      <el-form :inline="true" class="mb20" size="small" v-model="merchantDataForm" ref="merchantDataForm" :rules="merchantDataFormRules">
        <el-row class="mb30">
          <el-form-item label="商家名称：" class="w178">
            <el-input v-model="merchantDataForm.name" placeholder="商品名称" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商家编码：" class="w178">
            <el-input v-model="merchantDataForm.orgNumber" placeholder="商品编码" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商家类型：" prop="merchantType" class="w178">
            <el-select v-model="merchantDataForm.merchantType" placeholder="全部" clearable>
              <el-option label="自营商家" value="1"></el-option>
              <el-option label="第三方商户" value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row class="w100">
          <el-form-item class="w100 t_r marginZero">
            <el-button class="resetButton" icon="el-icon-refresh" @click="restMerchantForm">重置</el-button>
            <el-button class="searchButton" icon="el-icon-search" @click="queryPageMerchantManagement">搜索</el-button>
          </el-form-item>
        </el-row>
      </el-form>
      <div class="table-section">
        <el-table
          :data="merchantTableData"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="addMerchantChangeSelect"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="orgNumber" label="商家编码" sortable align="center"></el-table-column>
          <el-table-column prop="name" label="商家名称" align="center"></el-table-column>
          <el-table-column prop="merchantType" label="商家类型" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.merchantType == '1'">自营商家</span>
              <span v-else-if="scope.row.merchantType == '2'">第三方商家</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="chosenSelect">
        <span>
          已选择商家：
          {{addMerchantSelect.length}}
        </span>
        <div class="t_r" v-if="merchantTableData.length > 0">
          <el-pagination
            @size-change="merchanthandleSizeChange"
            @current-change="merchanthandleCurrentChange"
            :current-page="merchantDataForm.start"
            :page-sizes="[10]"
            :page-size="merchantDataForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="merchantListTotal"
          ></el-pagination>
        </div>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button class="cancelButton" @click="dialogVisibleMerchant=false" size="mini">取消</el-button>
        <el-button class="searchButton" @click="addMerchantChange" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisibleStore" title="添加店铺" :close-on-click-modal="false">
      <el-form :inline="true" class="mb20" size="small" v-model="storeDataForm" ref="storeDataForm" :rules="storeDataFormRules">
        <el-row class="mb30">
          <el-form-item label="店铺名称：" class="w178 mb30">
            <el-input v-model="storeDataForm.storeName" placeholder="店铺名称" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="店铺编码：" class="w178">
            <el-input v-model="storeDataForm.storeCode" placeholder="店铺编码" clearable maxlength="80"></el-input>
          </el-form-item>
            <el-form-item label="所属商家名称：" prop="merchantName" class="w178">
              <el-input clearable
                        v-model="storeDataForm.merchantName"
                        placeholder="所属商家名称"
                        size="mini" maxlength="80"
              ></el-input>
            </el-form-item>
            <el-form-item label="店铺类型：" prop="storeType" class="w178">
              <el-select v-model="storeDataForm.storeType" placeholder="全部" size="mini" clearable>
                <el-option label="自营店铺" value="0"></el-option>
                <el-option label="入驻店铺" value="1"></el-option>
              </el-select>
            </el-form-item>
        </el-row>
        <el-row class="w100">
          <el-form-item class="w100 t_r marginZero">
            <el-button class="resetButton" icon="el-icon-refresh" @click="restStoreForm('storeDataForm')">重置</el-button>
            <el-button class="searchButton" icon="el-icon-search" @click="queryPageStoreList">搜索</el-button>

          </el-form-item>
        </el-row>
      </el-form>
      <div class="table-section">
        <el-table
          :data="storeAddTableData"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="addStoreChangeSelect"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="storeCode" label="店铺编码" sortable align="center" width="300"></el-table-column>
          <el-table-column prop="storeName" label="店铺名称" align="center"></el-table-column>
           <el-table-column label="店铺类型" align="center">
              <template slot-scope="scope">
                  　{{scope.row.storeType == '0' ? '自营店铺' : '入驻店铺'}}
                </template>
            </el-table-column>
            <el-table-column prop="merchantName" label="所属商家" align="center"></el-table-column>
        </el-table>
      </div>
      <div class="chosenSelect">
        <span>
          已选择店铺：
          {{addStoreSelect.length}}
        </span>
        <div v-if="storeAddTableData.length > 0" class="t_r">
          <el-pagination
            @size-change="storehandleSizeChange"
            @current-change="storehandleCurrentChange"
            :current-page="storeDataForm.start"
            :page-sizes="[10]"
            :page-size="storeDataForm.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="storeListTotal"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelButton" @click="dialogVisibleStore=false" size="mini">取消</el-button>
        <el-button class="searchButton" @click="addStoreChange" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisibleTwo" title="添加商品" :close-on-click-modal="false">
      <el-form :inline="true" class="mb20" size="small" v-model="formInline" ref="formInline" :rules="formInlineRules">
        <el-row class="mb30">
          <el-form-item label="商品名称：" class="w178">
            <el-input v-model="formInline.chineseName" placeholder="商品名称" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商品编码：" class="w178">
            <el-input v-model="formInline.code" placeholder="商品编码" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商品分类：" class="w178">
            <el-input v-model="formInline.categoryName" placeholder="商品类目" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="所属商户：" class="w178">
            <el-input v-model="formInline.storeName" placeholder="所属商户" clearable maxlength="80"></el-input>
          </el-form-item>
          <el-form-item label="商户Code：" class="w178">
            <el-input v-model="formInline.storeCode" placeholder="商户Code" clearable maxlength="80"></el-input>
          </el-form-item>
        </el-row>
      </el-form>
      <el-row class="t_r mb30">
            <el-button class="searchButton" icon="el-icon-search" @click="queryPageProductManagement">搜索</el-button>
            <el-button class="resetButton" icon="el-icon-refresh" @click="restForm">重置</el-button>
        </el-row>
      <div class="table-section">
        <el-table
          :data="tableDataTwo"
          v-loading="productListloading"
          :header-cell-style="tableHeaderColor"
          ref="multipleTable"
          :row-class-name="tableRowClassName"
          :size="size"
          @selection-change="selectAddProductChange"
        >
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="thirdSpuId" label="商品编码" sortable align="center"></el-table-column>
          <el-table-column prop="goodsName" label="商品名称" align="center"></el-table-column>
          <el-table-column prop="goodsCategory" label="商品类目" align="center"></el-table-column>
          <el-table-column prop="storeName" label="所属商户" align="center"></el-table-column>
          <el-table-column prop="storeCode" label="商户Code" align="center"></el-table-column>
          <el-table-column prop="salePriceScope" label="原价（元）" align="center"></el-table-column>
          <!-- <el-table-column prop="stock" label="库存" align="center"></el-table-column> -->
        </el-table>
      </div>
      <div class="chosenSelect">
        <span>已选择商品：{{selectAddProduct.length}}</span>
        <div v-if="tableDataTwo.length > 0" style="float:right;">
          <el-pagination
            @size-change="producthandleSizeChange"
            @current-change="producthandleCurrentChange"
            :current-page="formInline.start"
            :page-sizes="[10]"
            :page-size="formInline.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="productListTotal"
          ></el-pagination>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelButton" @click="dialogVisibleTwo=false" size="mini">取消</el-button>
        <el-button class="searchButton" @click="addProductChange" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog class="el-dialog-style" title="审核" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
      <el-form :model="form" ref="form" :rules="formRules">
        <el-form-item class="textarea" prop="checkRemark">
          <el-input v-model="form.checkRemark" autocomplete="off" type="textarea" rows="6" clearable></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelButton" @click="reviewDialogNo(4)" size="mini">不通过</el-button>
        <el-button class="searchButton" @click="reviewDialog(11)" size="mini">通过</el-button>
      </div>
    </el-dialog>


    <el-dialog title="上传图片选择" :visible.sync="uploadMethodVisible" class="el-dialog-style" :close-on-click-modal="false">
      <el-upload
        class="mb30 uploadStyle t_c"
        drag
        :on-success="imgUploadSuccess"
        :on-error="imgUploadError"
        :show-file-list="showFileList"
        :auto-upload="autoUpload"
        :http-request="uploadMethod"
      >
        <el-button type="primary" class="searchButton">本地上传</el-button>
      </el-upload>
<!--      <div class="t_c">-->
<!--        <el-button class="searchButton" @click="materialLibraryVisible=true">素材库上传</el-button>-->
<!--      </div>-->
    </el-dialog>

    <!-- 素材库 -->
    <el-dialog title="选择图片" :visible.sync="materialLibraryVisible" :close-on-click-modal="false">
      <div>
        <el-container>
          <el-aside width="240px" class="mr30">
            <div class="tab-container-dialog">
            <el-tabs
              v-model="treeActiveName"
              type="card"
              @tab-click="handleClick"
              :stretch="stretch"
            >
              <el-tab-pane label="我的素材" name="1">
                <el-tree :data="localTreeList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
              </el-tab-pane>
              <el-tab-pane label="平台素材" name="2">
                <el-tree :data="deptTreeList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
              </el-tab-pane>
            </el-tabs>
            </div>
          </el-aside>
          <el-main>
            <div class="material-main">
              <div class="material-header">
                <div class="material-title-left">{{materialTitle}}</div>
                <div
                  class="material-title-right"
                  v-if="materialQueryPageFilters.categoryId != null"
                >
                  <el-input
                    type="text"
                    v-model="materialQueryPageFilters.materialName"
                    placeholder="请输入素材名称"
                    size="mini"
                    style="width:180px"
                    clearable
                  ></el-input>
                  <el-button icon="el-icon-search" size="mini" @click="handleNodeClick" class="searchButton">搜索</el-button>
                </div>
              </div>
              <div class="material-main-list mb30">
                <!-- <div :class="[materialList[index].isSelect == true ? 'material-main-item-name-select material-main-item' : 'material-main-item']" v-for="(item , index) in materialList" :key="index" @click="selectMaterial(index)"> -->
                <div
                  class="material-main-item"
                  :class="[materialList[index].isSelect == true ? 'material-main-item-select' : '']"
                  v-for="(item , index) in materialList"
                  :key="index"
                  @click="selectMaterial(index)"
                >
                  <div class="material-main-item-img">
                    <img :src="item.materialUrl" style="width:100%;height: 100%;" />
                  </div>
                  <div class="material-main-item-name">{{item.materialName}}</div>
                </div>
                <div v-if="materialList.length < 1" style="text-align: center;width: 100%;">暂无数据</div>
              </div>
              <div class="chosenSelect">
                <span v-if="materialImgNumber.length > 0">已选择图片：{{materialImgNumber}}</span>
                <div v-if="materialList.length > 0" class="t_r  w100">
                  <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="materialQueryPageFilters.start"
                    :page-sizes="[10]"
                    :page-size="materialQueryPageFilters.limit"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="materialListTotal"
                  ></el-pagination>
                </div>
              </div>
            </div>
          </el-main>
        </el-container>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelButton" @click="materialLibraryVisible=false" size="mini">取消</el-button>
        <el-button class="searchButton" @click="addMaterial" size="mini">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { formatDate } from "@/utils/datetime";
import KtButton from "@/views/Core/KtButton";
import { getAllRow, changeChild, changeParent } from "@/assets/js/tableTree.js";
import axios from "axios";
export default {
  components: {
    KtButton
  },
  data() {
    let this_ = this;
    // var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？ ]");
    var reg = /^[\u0391-\uFFE5A-Za-z0-9]+$/;
    var checkPromName = (rule, value, callback) => {
      //
      if (!value) {
        return callback(new Error("请输入活动名称"));
      } else if (value.length < 3 || value.length > 60) {
        return callback(new Error("名称长度在 3 到 60 个字符"));
      } else {
        callback();
      }
    };

    var checkSeckillTime = (rule, value, callback) => {
      //
      if (!value || !value[0]) {
        return callback(new Error("请选择活动开始时间"));
      } else if (!value[1]) {
        return callback(new Error("请选择活动结束时间"));
      } else if (value[0] >= value[1]) {
        return callback(new Error("活动开始时间不能大于结束时间"));
      } else {
        callback();
      }
    };
    var checkWaringNum = (rule, value, callback) => {
      if(value && Number(value) > 100){
        return callback(new Error("必须小于等于100%"));
      }else{
        return callback();
      }
    };
    var checkStartTimeEveryDay = (rule, value, callback) => {
      let timeEveryDay = this_.dataForm.TimeEveryDay;
      if (!this_.dataForm.startTimeEveryDay) {
        return callback(new Error("请选择每日时间段开始时间"));
      } else if (
        this_.dataForm.endTimeEveryDay == undefined ||
        this_.dataForm.endTimeEveryDay == ""
      ) {
        return callback(new Error("请选择每日时间段结束时间"));
      } else if (
        Number(this_.dataForm.endTimeEveryDay.split(":")[0]) <=
        Number(this_.dataForm.startTimeEveryDay.split(":")[0])
      ) {
        return callback(new Error("每日时间段结束时间不能大于或等于开始时间"));
      } else if (timeEveryDay != undefined && timeEveryDay.length > 0) {
        timeEveryDay.forEach(item => {
          if (
            item.startTimeOfDate == undefined ||
            this.dataForm.startTimeOfDate == ""
          ) {
            return callback(new Error("请选择每日时间段开始时间"));
          } else if (
            //item.endTimeOfDate == undefined ||
            this.dataForm.endTimeOfDate == ""
          ) {
            return callback(new Error("请选择每日时间段结束时间"));
          } else if (
            Number(item.endTimeOfDate.split(":")[0]) <=
            Number(item.startTimeOfDate.split(":")[0])
          ) {
            return callback(
              new Error("每日时间段结束时间不能大于或等于开始时间")
            );
          }
          let flag = this_.isDateIntersection(
            this_.dataForm.startTimeEveryDay,
            this_.dataForm.endTimeEveryDay,
            item.startTimeOfDate,
            item.endTimeOfDate
          );
          if (flag) {
            return callback(new Error("每日时间段不可重叠"));
          }
          callback();
        });

        //   if(timeEveryDay.length == 1){
        //     //判断是否有重叠时间
        //
        //     if(timeEveryDay[0].startTimeOfDate != undefined && this_.dataForm.endTimeEveryDay != undefined){
        //         let startTime = timeEveryDay[0].startTimeOfDate.split(":")[0];
        //         let endTime = this_.dataForm.endTimeEveryDay.split(":")[0];
        //         if(Number(endTime) > Number(startTime)){
        //             return callback(new Error('每日时间段不可重叠'));
        //         }
        //     }
        //   }else{

        // timeEveryDay.forEach(item=>{
        //     let endTime = item.endTimeOfDate;
        //     for(let index = 0; index < timeEveryDay.length ; index++){
        //
        //         if(timeEveryDay[index+1] != undefined){
        //             if(Number(endTime.split(":")[0]) > Number(timeEveryDay[index+1].startTimeOfDate.split(":")[0])){
        //                 return callback(new Error('每日时间段不可重叠'));
        //             }
        //         }
        //     }
        // })
        //
        // let endTime = this_.dataForm.endTimeEveryDay.split(":")[0];
        // timeEveryDay.forEach(item=>{
        //     if(Number(endTime) < Number(item.startTimeOfDate.split(":")[0])){
        //         return callback(new Error('每日时间段不可重叠'));
        //     }
        // })
        //   }
      } else {
        callback();
      }
    };

    var checkParentAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入母平台分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("母平台分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkChildAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入子平台分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("子平台分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkMerchantAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入商家分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("商家分摊比例格式错误"));
      } else {
        callback();
      }
    };
    var checkStoreAllocationScale = (rule, value, callback) => {
      if (!value) {
        callback(new Error("请输入店铺分摊比例"));
      } else if (!/^[1-9][0-9]*([.][0-9]{1,2})?$/.test(value)) {
        //分摊比例为整数或两位小数
        callback(new Error("店铺分摊比例格式错误"));
      } else {
        callback();
      }
    };



    var isNumber = (rule, value, callback) => {
      if (value === "") {
        return callback();
      } //这是用来判断如果不是必须输入的，则直接跳出
      const r = /^\+?[1-9][0-9]*$/; // 正整数
      // 如果判断不符合正则，则不是正整数不能提交
      if (!r.test(value)) {
        return callback(new Error("必须为正整数"));
      } else {
        // if (
        //   this.filters.parentAllocationScale != undefined &&
        //   this.filters.childAllocationScale != undefined &&
        //   this.filters.merchantAllocationScale != undefined &&
        //   this.filters.storeAllocationScale != undefined
        // ) {
        let countScale =
          Number(this.dataForm.parentAllocationScale) +
          Number(this.dataForm.childAllocationScale) +
          Number(this.dataForm.merchantAllocationScale) +
          Number(this.dataForm.storeAllocationScale);
        if (countScale != 100) {
          return callback(new Error("加起来必须等于100%"));
        } else {
          this.$refs.dataForm.clearValidate("parentAllocationScale");
          this.$refs.dataForm.clearValidate("childAllocationScale");
          this.$refs.dataForm.clearValidate("merchantAllocationScale");
          this.$refs.dataForm.clearValidate("storeAllocationScale");
          return callback();
        }
        // }
        // return callback();
      }
    };

    /**
     * 校验会员等级
     */
    var checkMemLevel = (rule, value, callback) => {
      //查看每个子平台是否都选中了
      let memberGradeList = this.memberGradeList;
      if(memberGradeList == null || memberGradeList.length < 1){
          return callback(new Error("会员等级不能为空"));
      }
      let flag = false;
      for(var i = 0; i< memberGradeList.length ; i++){
       for(var i = 0; i< memberGradeList.length ; i++){
        if((memberGradeList[i].levelSelectList == null || memberGradeList[i].levelSelectList.length < 1 )&& !memberGradeList[i].checkAll){
            flag = true;
            break;
          }
        }
      }
      if(flag){
            return callback(new Error("每个平台必须选中一个会员等级"));
      }
      return callback();
    };

    /**
     * 会员类型
     */
    var checkMemType = (rule, value, callback) => {
      if(this.selectMemTypes == null || this.selectMemTypes.length < 1){
        return callback(new Error("请选择会员类型"));
      }

      return callback();

    };
    /**
     * 新老用户
     */
    var checkUserType = (rule, value, callback) => {
      if(this.selectUserType == null || this.selectUserType.length < 1){
        return callback(new Error("请选择新老用户"));
      }
      return callback();
    };

    return {
      channelOption:[],
      merchantStaticDataFormRules: {
        // orgNumber: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        // merchantName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
      },

      merchantDataFormRules: {
        // orgNumber: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        // name: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
      },

      storeStaticDataFormRules: {
        // storeCode: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        // storeName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
      },

      storeDataFormRules: {
        // storeName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        // storeCode: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
      },

      formInlineRules: {
        // goodsName: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        // thirdSpuId: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
        // goodsCategory: { min: 0, max: 80, message: "字数0-80个字符", trigger: "blur" },
      },

      // 活动时间校验
      timeCheck: {
        disabledDate: time => {
          if (this.promotionStartEndTime) {
            return (
              time.getTime() < Date.now() - 8.64e7 ||
              time.getTime() > new Date(this.promotionStartEndTime).getTime()
            );
          } else {
            return time.getTime() < Date.now() - 8.64e7;
          }
        }
      },
      templateDialogFormVisible: false, //模板弹窗
      templateForm: {}, //模板model
      maxTime: "25:00",
      formLabelWidth: "120px",
      dialogFormVisible: false,
      form: {},
      formRules:{
        checkRemark: [
          { required: true, message: "审核意见不能为空", trigger: "blur" }
        ]
      },
      row: {},
      couponId: 0,
      activeName: "1",
      shenhe: 0,
      productListloading: true,
      selectedOptions: [],
      formInline: {
        商品类目: "1",
        商品品牌: "1",
        goodsCategory:"",
        goodsName:"",
        thirdSpuId:"",
        start: 1,
        limit: 10
      },
      tabsIndex: "first",
      tableData: [],
      tableDataTwo: [],
      dialogImageUrl: "",
      dialogVisible: false,
      dialogVisibleTwo: false,
      size: "mini",
      active: this.$route.params.active==null? 1 : Number(this.$route.params.active),
      dataForm: {
         warningProportion:null,
        activityBudget:null,
        activitySearch:null,
        grantType: "0",
        useChannel: [],
        startTime: new Date(),
        endTime: new Date(),
        TimeEveryDay: [],
        costAllocationFlag: "1", //是否分摊
        parcelsFlag: "1", //是否包邮
        overLimitRule: "1", //超限规则
        fileList: [], //图片List,
        channelIds: [],
        storeCode: "0", //店铺地址
        merchantCode: "0", //商家地址
        proUserType: "0", //新老用户
        frontPromType: 4000,
        promType: "4",
        label: "",
        status: null,
        parentAllocationScale: "",
        childAllocationScale: "",
        merchantAllocationScale: "",
        storeAllocationScale: "",
      },
      addTimeEveryDayBtnStatus: false,
      labelPosition: "right",
      tagsList: [],
      addTagDialogFormVisible: false,
      addTagForm: {},
      addTagRules: {
        categoryId: [
          { required: true, message: "请选择标签分类", trigger: "change" }
        ],
        tagName: [
          { required: true, message: "请输入标签名称", trigger: "blur" }
        ]
      },
      tagCategoryList: [],
      //选择上传方式
      uploadMethodVisible: false,
      showFileList: false, //是否显示文件列表
      imgUrlList: [], //图片上传
      autoUpload: true, //图片自动上传
      materialLibraryVisible: false, //素材库弹窗
      materialImgNumber: 0, //选择素材数
      localTreeList: [], //本地树
      deptTreeList: [], //平台树
      defaultProps: {
        children: "treeInfoList",
        label: "categoryName"
      },
      //treeActiveName
      treeActiveName: "1",
      //查询素材列表分页
      materialQueryPageFilters: {
        start: 1,
        limit: 10,
        materialName: null
      },
      //素材分类tabs选项卡是否自动撑开
      stretch: true,
      //素材列表页title
      materialTitle: "",
      //素材List
      materialList: [],
      materialListTotal: 0, //素材列表总条数
      channelList: [], //渠道Tree List
      channlProps: {
        label: "childName"
      },
      //多选商家
      multipleMerchantSelection: [],
      //商家弹窗Form
      merchantTableData: [],
      merchantDataForm: {
        name: null,
        orgNumber: null,
        merchantType: null,
        start: 1,
        limit: 10
      }, //商家搜索条件
      dialogVisibleMerchant: false, //商家弹窗
      //商家列表分页
      merchantListTotal: 0,
      multipleStoreSelection: [], //静态店铺多选
      addMerchantSelect: [], //新增商家选择
      storeTableData: [], //店铺列表静态
      dialogVisibleStore: false, //新增店铺窗口

      storeDataForm: {
        storeCode: "",
        storeName: "",
        storeType:"",
        merchantName:"",
        start: 1,
        limit: 10
      },
      storeAddTableData: [],
      addStoreSelect: [],
      storeListTotal: 0,

      //选择商品
      proActiveName: "1",
      activeProductName: "1",
      productTableData: [{


      }], //商品列表 静态表格
      selectAddProduct: [], //弹窗选择商品
      productListTotal: 0, //弹窗列表total
      productSelectFlag: [], //选择商品
      periodList: [],
      //时间段id
      timeOfDateId: "",
      skillId:
        this.$route.params.promotionId == null
          ? "0"
          : this.$route.params.promotionId,
      dataFormRules: {
        activityBudget: [
          { required: true, message: "请输入活动预算", trigger: "blur" }
        ],
        warningProportion: [
          { required: false, validator: checkWaringNum, trigger: ["change","blur"] }
        ],
        costAllocationFlag: [
          {
            required: true,
            message: "请选择是否分摊",
            trigger: "change"
          }
        ],
        promName: [
          { required: true, validator: checkPromName, trigger: "blur" }
        ],
        SeckillTime: [
          { required: true, validator: checkSeckillTime, trigger: "blur" }
        ],
        startTimeEveryDay: [
          { required: true, validator: checkStartTimeEveryDay, trigger: "blur" }
        ],
        parentAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        childAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        merchantAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        storeAllocationScale: [
          {
            required: true,
            validator: isNumber,
            trigger: "change"
          }
        ],
        // proUserType: [
        //   { required: true, message: "请选择用户类型", trigger: "change" }
        // ],
        selectUserType: [{ required: true, validator: checkUserType, trigger: "change" }],
        channelIds: [
          { required: true, message: "请选择使用渠道", trigger: "checked" }
        ],
        storeCode: [
          { required: true, message: "请选择店铺地址", trigger: "change" }
        ],
        merchantCode: [
          { required: true, message: "请选择商家地址", trigger: "change" }
        ],

        levelSelectList: [{ required: true , validator: checkMemLevel, trigger: "blur"}] ,
        selectMemTypes: [{required: true, validator: checkMemType , trigger: "change"}]

      },
      deptType: localStorage.getItem("deptType"), //当前登录用户所属组织类型
      //商家页分页
      merchantStaticDataForm: {
        orgNumber:null,
        merchantName: null,
        start: 1,
        limit: 10
      },
      merchantTotal: 0,

      //商家页分页
      storeStaticDataForm: {
        storeCode: null,
        storeName: null,
        start: 1,
        limit: 10
      },
      storeTotal: 0,
      //商品也分页查询
      goodsTotal: 0,
      skuTotal: 0,
      goodsStaticDataForm: {
        start: 1,
        limit: 10
      },
      // 活动时间校验
      timeCheck: {
        disabledDate: time => {
          if (this.promotionStartEndTime) {
            return (
              time.getTime() < Date.now() - 8.64e7 ||
              time.getTime() > new Date(this.promotionStartEndTime).getTime()
            );
          } else {
            return time.getTime() < Date.now() - 8.64e7;
          }
        }
      },
      //默认勾选tree
      defaultCheckedKeys: [],

      showSeachMerchant: false, //是否显示商家搜索框
      showSeachStore: false, //是否显示店铺搜索框

      activeTab: 'noMutexProduct',
      noMutexProductLabel:"生效商品（0）",
      mutexProductForm:{
        promotionId: this.$route.params.promotionId == null
          ? "0"
          : this.$route.params.promotionId,
        mutexFlag:1,//互斥标识
        start: 1,
        limit: 10
      },
      mutexProductList:[{
        goodsCode:"sku12333",
        goodsName:"iphone6s",
        goodsTypeName:"手机",
        reserveNum:"200",
        goodsPrice:"09.-9.9",
        storeName:"张大仙",
        storeName:"ZDX",

      }],
      mutexProductTotal:0,
      mutexProductLabel:"互斥商品（0）",
      showButtons:true,
      mutexPromotionForm:{
        promotionId: this.$route.params.promotionId == null
          ? "0"
          : this.$route.params.promotionId,
        promType:6,
        start:1,
        limit:10,
      },
      mutexPromotionList:[],
      mutexPromotionListTotal:0,
      mutexPromotionVisible:false,
      batchRenewAddSelection:[],

      isAllChecked: false,//全选
      isIndeterminateCheck: false,//全选 checkbox 的不确定状态
      allData: [],//全选 操作数据

      isAllProductChecked: false,//全选
      isIndeterminateProductCheck: false,//全选 checkbox 的不确定状态
      allProductData: [],//全选 操作数据

      //商品搜索
      queryGoodsReuqest:{
        goodsType: null,
        goodsName: null,
        goodsCode: null,
        storeId: null,
      },
      searchGoodsFlag: false,

      //会员等级 会员类型
      memberGradeList: [],
      reloadMemLevel: true,

      //会员类型
      memTypeCheckAll: true,
      selectMemTypes:[1,2,3],
      channelId:[1,2,3],
      channelIdCheckAll:true,
      channelIdIsIndeterminate:false,
      memTypeIsIndeterminate: false,
      userTypeCheckAll: true,
      selectUserType:[1,2],
      userTypeIsIndeterminate: false,
    };
  },
  methods: {
    // 模板下载
    downloadTemplate() {
      window.location.href =
        this.utils.getHost() + "jic-market/resource/download?key=FULL";
    },
    queryChannelListOther: function() {
      var this_ = this;
      this.utils.request.queryChannelListOther({}, function(res) {
        if (res.code == "0000") {
          this_.channelOption = res.data;
        }
      });
    },
    //新老用户
    handleCheckAllUserTypeChange(val) {
      this.selectUserType = val ? [1,2] : [];
      this.userTypeIsIndeterminate = false;
    },
    handleCheckedUserTypeChange(value) {
      let checkedCount = value.length;
      this.userTypeCheckAll = checkedCount === 2;
      this.userTypeIsIndeterminate = checkedCount > 0 && checkedCount < 2;
    },
    getUuid() {
      var s = [];
      var hexDigits = "0123456789abcdef";
      for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
      s[8] = s[13] = s[18] = s[23] = "-";

      var uuid = s.join("");
      return uuid;
    },
    //使用渠道选中时触发
    // channelChange(callback){
    //   let deptNodeList = [];
    //   let deptIds = [];
    //   if(this.deptType == 0){
    //       deptNodeList = this.$refs.channelTree.getCheckedNodes();
    //       deptIds = deptNodeList.map((item,index) =>{
    //         return item.deptId;
    //       })
    //       if(deptIds.indexOf("179") == -1){
    //         deptIds.unshift("179");
    //         deptNodeList.unshift({"deptId":179,"childName":"卡奥斯运营中心","id":179})
    //       }
    //
    //   }else{
    //     //查询子平台信息
    //     let deptId = localStorage.getItem("deptId");
    //     deptIds.push(deptId);
    //     let userInfo = JSON.parse(localStorage.getItem("user"));
    //     deptNodeList.push({deptId:userInfo.deptId,"childName":userInfo.deptName,"id":userInfo.businessId})
    //   }
    //
    //
    //   this.utils.request.listMemberGradeForMarket({"deptIds": deptIds.join(",")},res=>{
    //     if(res.code == '0000'){
    //         let levelList = res.data;
    //         let restLevelInfo =  [];
    //         //如果存在排除重新赋值
    //         this.memberGradeList.forEach(levelItem=>{
    //           let levelInfo = levelList.find(function(level) {
    //             return levelItem.deptId == level.deptId;
    //           })
    //           if(levelInfo != undefined){
    //              restLevelInfo.push(levelItem);
    //           }
    //         })
    //         //遍历
    //         this.memberGradeList = restLevelInfo;
    //         for(let deptInfo of deptNodeList){
    //           let levelItem = this.memberGradeList.find(function(level) {
    //             return deptInfo.deptId == level.deptId;
    //           })
    //           if(levelItem != undefined){
    //             continue;
    //           }
    //           //如果不勾选子平台 删除已有子平台
    //
    //           let levelInfo = levelList.find(function(level) {
    //             return level.deptId == deptInfo.deptId;
    //           })
    //           if(levelInfo == undefined){
    //             this.memberGradeList.push({ deptId: deptInfo.deptId, childName: deptInfo.childName, businessId: deptInfo.id ,checkAll: true, isIndeterminate: false,  levelSelectList: [], levelList:[]})
    //           }else{
    //             //添加数据
    //             let selectLevelIds = levelInfo.mememberGradeResponseList.map((item,index) =>{
    //               return item.id;
    //             })
    //             levelInfo.mememberGradeResponseList.forEach(item=>{
    //               item.key = this.getUuid();
    //             })
    //             this.memberGradeList.push({deptId: deptInfo.deptId, childName: deptInfo.childName, businessId: deptInfo.id ,  levelSelectList: selectLevelIds,  checkAll: true , isIndeterminate: false , levelList:levelInfo.mememberGradeResponseList})
    //           }
    //         }
    //     }else{
    //       this.memberGradeList = [];
    //     }
    //     this.$nextTick(()=>{
    //       if(callback != undefined){
    //         callback();
    //       }
    //     })
    //   })
    //   // this.getMemLevelList(deptIds.join(","))
    // },
    getMemberList(){
      var this_=this;
      let deptIds = [];
      let deptId = localStorage.getItem("deptId");
      deptIds.push(deptId);
      this.utils.request.listMemberGradeForMarket({"deptIds": deptIds.join(",")},res=>{
          if(res.code == '0000'){
          let levelList = res.data;
          var restLevelInfo =  [];
          //如果存在排除重新赋值
          levelList[0].mememberGradeResponseList.forEach(item=>{
            var obj={};
            obj.deptId=item.id;
            obj.childName=item.levelName;
            restLevelInfo.push(obj);
          })
          //遍历
          this_.memberGradeList = restLevelInfo;
        }else{
          this_.memberGradeList = [];
        }
      })
    },
    //会员类型
    handleCheckAllMemTypeChange(val) {
      this.selectMemTypes = val ? [1,2,3] : [];
      this.memTypeIsIndeterminate = false;
    },
    handleCheckedMemTypeChange(value) {
      let checkedCount = value.length;
      this.memTypeCheckAll = checkedCount === 3;
      this.memTypeIsIndeterminate = checkedCount > 0 && checkedCount < 3;
    },

    //渠道
      handleCheckAllChannelIdChange(val) {
        this.channelId = val ? [1,2,3] : [];
        this.channelIdIsIndeterminate = false;
      },
      handleCheckedChannelIdChange(value) {
        let checkedCount = value.length;
        this.channelIdCheckAll = checkedCount === 3;
        this.channelIdIsIndeterminate = checkedCount > 0 && checkedCount < 3;
      },

    /**
     * 重置商品搜索
     */
    resetStaticGoodsSearch(){
      if (this.$refs['queryGoodsReuqest'] != undefined) {
        this.$refs['queryGoodsReuqest'].resetFields();
      }
      this.goodsStaticDataForm.start = 1;
      this.goodsStaticDataForm.limit = 10;
      this.skillQueryGoods();
    },
    /**
     * 状态格式化
     */
    statusFormat(row) {
      if (
        row.status == 1 &&
        new Date().getTime() <= new Date(row.startTime).getTime()
      ) {
        //待提交
        return 11;
      } else if (
        row.status == 2 &&
        new Date().getTime() <= new Date(row.startTime).getTime()
      ) {
        //待审核
        return 12;
      } else if (
        row.status == 11 &&
        new Date().getTime() <= new Date(row.startTime).getTime()
      ) {
        //未开始
        return 13;
      } else if (
        row.status == 4 &&
        new Date().getTime() <= new Date(row.startTime).getTime()
      ) {
        //审核未通过
        return 14;
      } else if (
        row.status == 11 &&
        new Date().getTime() >= new Date(row.startTime).getTime() &&
        new Date().getTime() <= new Date(row.endTime).getTime()
      ) {
        //进行中
        return 15;
      } else if (
        (row.status == 1 || row.status == 2 || row.status == 4) &&
        new Date().getTime() > new Date(row.startTime).getTime()
      ) {
        //已过期
        return 16;
      } else if (
        row.status == 11 &&
        new Date().getTime() > new Date(row.endTime).getTime()
      ) {
        //已结束
        return 17;
      }
    },
    /*
      备注无法编辑
     */
    changeRemark(val) {
      this.$forceUpdate();
    },
    /**
     * 搜索商家
     */
    merchantSearch(){
        this.merchantStaticDataForm.start = 1;
        this.merchantStaticDataForm.limit = 10;
        this.skillQueryMerchant();
    },

    resetMerchantSearch(){
        this.merchantStaticDataForm.start = 1;
        this.merchantStaticDataForm.limit = 10;
        this.merchantStaticDataForm.orgNumber = null;
        this.merchantStaticDataForm.merchantName = null;
        this.skillQueryMerchant();
    },

    /**
     * 搜索店铺
     */
    storeSearch(){
        this.storeStaticDataForm.start = 1;
        this.storeStaticDataForm.limit = 10;
        this.skillQueryStore();
    },

    resetstoreSearch(){
        this.storeStaticDataForm.start = 1;
        this.storeStaticDataForm.limit = 10;
        this.storeStaticDataForm.storeCode = null;
        this.storeStaticDataForm.storeName = null;
        this.skillQueryStore();
    },


    /**
     * 清空店铺输入框
     */
    restStoreForm() {
      this.$set(this.storeDataForm, "storeCode", null);
      this.$set(this.storeDataForm, "storeName", null);
      this.$set(this.storeDataForm, "storeType", null);
      this.$set(this.storeDataForm, "merchantName", null);
      this.$set(this.storeDataForm, "start", 1);
      this.queryPageStoreList();
    },
    /**
     * 添加全部商品
     */
    saveAllGoods() {
      // const loading = this.$loading({
      //   lock: true,
      //   text: "小的正在加载中,请稍后...",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.7)"
      // });
      this.utils.request.skillAddAllGoods(
        { promotionId: this.skillId, skillTimeId: this.timeOfDateId },
        res => {
          // loading.close();
          this.goodsCurrentChange(1);
          this.getMutexProductList();
        }
      );
    },
    /**
     * 商品页分页
     */
    goodsSizeChange() {},
    goodsCurrentChange(val) {
      this.goodsStaticDataForm.start = val;
      this.skillQueryGoods();
    },
    /**
     * 商家页分页
     */
    merchantSizeChange() {},
    merchantCurrentChange(val) {
      this.merchantStaticDataForm.start = val;
      this.skillQueryMerchant();
    },
    /**
     * 店铺
     */
    storeSizeChange() {},
    storeCurrentChange(val) {
      this.storeStaticDataForm.start = val;
      this.skillQueryStore();
    },
    /**
     * 清空商家搜索框
     */
    restMerchantForm() {
      this.$set(this.merchantDataForm, "orgNumber", "");
      this.$set(this.merchantDataForm, "name", "");
      this.$set(this.merchantDataForm, "merchantType", "");
      this.$set(this.merchantDataForm, "start", 1);
      this.queryPageMerchantList();
    },
    /**
     * 弹窗条件查询商家
     */
    queryPageMerchantManagement() {
      this.merchantDataForm.start = 1;
      this.queryPageMerchantList();
    },
    /**
     * 保存模板
     */
    saveTemplate() {
      var that = this;
      this.templateForm.promotionId = this.skillId;
      if (
        this.templateForm.templateName == null ||
        this.templateForm.templateName == ""
      ) {
        that.$message({ message: "模板名称不能为空", type: "error" });
        return false;
      }
      // const loading = this.$loading({
      //   lock: true,
      //   text: "小的正在加载中,请稍后...",
      //   spinner: "el-icon-loading",
      //   background: "rgba(0, 0, 0, 0.7)"
      // });
      this.utils.request.skillSaveTemplate(this.templateForm, res => {
        // loading.close();
        if (res.code == "0000") {
          this.$message({ message: "保存成功", type: "success" });
          this.templateDialogFormVisible = false;
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    isDateIntersection(start1, end1, start2, end2) {
      var startdate1 = start1.split(":")[0];
      var enddate1 = end1.split(":")[0];
      var startdate2 = start2.split(":")[0];
      var enddate2 = end2.split(":")[0];
      if (
        Number(startdate1) >= Number(startdate2) &&
        Number(startdate1) <= Number(enddate2)
      ) {
        return true;
      }
      if (
        Number(enddate1) > Number(startdate2) &&
        Number(enddate1) <= Number(enddate2)
      ) {
        return true;
      }
      if (
        Number(startdate1) <= Number(startdate2) &&
        Number(enddate1) >= Number(enddate2)
      ) {
        return true;
      }
      return false;
    },
    change(val) {},
    /**
     * 查询详情
     */
    getSkillDetail() {
      let that = this;
      this.utils.request.skillQueryConfig(
        { promotionId: this.skillId },
        res => {
          for (const key in res.data) {
            this.$set(that.dataForm, key, res.data[key]);
          }

          this.$set(that.dataForm, "status",this.statusFormat(res.data))

          //回显活动时间
          this.$set(that.dataForm, "SeckillTime", [
            new Date(res.data.startTime),
            new Date(res.data.endTime)
          ]);
          //回显时间段
          let responseInfoList = res.data.responseInfoList;
          that.responseInfoList = responseInfoList;
          this.$set(
            that.dataForm,
            "startTimeEveryDay",
            responseInfoList[0].startTimeOfDate
          );
          // [""] = ;
          this.$set(
            that.dataForm,
            "endTimeEveryDay",
            responseInfoList[0].endTimeOfDate
          );
          this.$set(
            that.dataForm,
            "TimeEveryDay",
            responseInfoList.slice(1, responseInfoList.length)
          );
          if(res.data["label"] != 0 && res.data["label"] != null && res.data["label"] != ""){
            this.$set(that.dataForm, "label", Number(res.data["label"]));
          }

          this.imgUrlList = [];

          res.data.imagesUrls.forEach(item => {
            this.imgUrlList.push({ url: item });
          });

          //回显使用渠道
          if (
            that.deptType == 0 &&
            res.data.channelCodes != null &&
            res.data.channelCodes.length > 0
          ) {
            this.$set(that.dataForm, "channelCodes", res.data.channelCodes);
            this.$set(that.dataForm, "channelIds", res.data.channelCodes);
            // that.$refs.channelTree.setCheckedKeys(res.data.channelCodes);
          }


          //新老用户
          let selectUserType = [];
          res.data.proUserType.split(",").forEach(item=>{
            selectUserType.push(Number(item));
          });
          that.selectUserType = selectUserType;
          if(selectUserType.length < 2){
            this.userTypeIsIndeterminate = true;
            this.userTypeCheckAll = false;
          }
          let _this = this;

          let selectMemTypes = [];
          res.data.memTypes.split(",").forEach(item=>{
            selectMemTypes.push(Number(item));
          });
          _this.selectMemTypes = selectMemTypes;
          if(selectMemTypes.length < 3){
            this.memTypeIsIndeterminate = true;
            this.memTypeCheckAll = false;
          }
          //渠道
            let channelId = [];
            res.data.channelId.split(",").forEach(item=>{
              channelId.push(Number(item));
            });
            _this.channelId = channelId;
            if(channelId.length < 3){
              this.channelIdIsIndeterminate = true;
              this.channelIdCheckAll = false;this.channelId
            }
        }
      );
    },
    /**
     * 修改商品价格
     */
    updateSkillPrice(row) {
       if(!this.checkProductLimits(row)){
        return false;
      }
      //TODO
      let param = {
        goodsInfoList: [
          {
            goodsId: row.id,
            goodsName: row.chineseName,
            goodsPrice: row.salePriceWithTax,
            goodsTypeId: row.productTypeId,
            goodsTypeName: row.fullNamePath,
            merchantChannelLimit: row.merchantChannelLimit,
            merchantId: row.merchantId,
            merchantName: row.merchantName,
            skillPrice: row.skillPrice,
            storeChannelLimit: row.storeChannelLimit,
            userChannelLimit: row.userChannelLimit,
            storeId: row.storeId,
            storeName: row.storeName,
            channelCode: "",
            goodsTypeId: row.goodsTypeId == null ? "" : row.goodsTypeId,
            deptShare:row.deptShare,
            merchantShare:row.merchantShare,
          }
        ],
        promotionId: this.skillId,
        skillTimeId: this.timeOfDateId
      };
      this.utils.request.skillUpdateGoods(param, res => {});
    },
    /**
     * 查询关联
     */
    skillQueryMerchant() {
      let that = this;
      this.merchantStaticDataForm.promotionId = this.skillId;
      this.utils.request.skillQueryMerchant(
        this.merchantStaticDataForm,
        res => {
          if (res != null && res.data != null) {
            that.tableData =
              res.data.merchantInfoList == null
                ? new Array()
                : res.data.merchantInfoList;
            let data = [];
            that.tableData.forEach(item => {
              data.push({
                merchantId: item.merchantId,
                orgNumber: item.orgNumber,
                name: item.merchantName,
                merchantType: item.merchantTypeId
              });
            });

            that.tableData = data;
            that.merchantTotal = Number(res.data.total);
          }
        }
      );
    },
    /**
     * 查询关联的店铺
     */
    skillQueryStore() {
      let that = this;
      this.storeStaticDataForm.promotionId = this.skillId;
      this.utils.request.skillQueryStore(this.storeStaticDataForm, res => {
        if (res != null && res.data != null) {
          this.storeTableData =
            res.data.storeInfoList == null ? [] : res.data.storeInfoList;
          let data = [];
          this.storeTableData.forEach(item => {
            data.push({
              id: item.storeId,
              storeCode: item.storeCode,
              storeName: item.storeName,
              merchantId: item.merchantId,
              merchantName: item.merchantName,
              storeType: item.storeType
            });
          });
          this.storeTableData = data;
          this.storeTotal = Number(res.data.total);
        }
      });
    },
    /**
     * 时间段选择
     */
    handleTitleClick(val) {
      this.timeOfDateId = val.name;

      this.goodsStaticDataForm.start = 1;
      this.goodsStaticDataForm.limit = 10;

      this.skillQueryGoods(val.index);
      this.getMutexProductList(val.index);
    },

    skillQueryGoods(index) {
      let that = this;
      this.timeOfDateId =
        index != null ? this.periodList[index].skillTimeId : this.timeOfDateId;
      this.goodsStaticDataForm.skillTimeId = this.timeOfDateId;
      this.goodsStaticDataForm.queryGoodsReuqest = this.queryGoodsReuqest;
      this.goodsStaticDataForm.promotionId = this.skillId;
      that.utils.request.skillQueryGoods(this.goodsStaticDataForm, data => {
        if (data != null) {

          that.productTableData = data.data.skillGoodsTimeResponseList[0].goodsInfoList;
          that.isAllProductChecked = false;
          that.isIndeterminateProductCheck = false;
          that.allProductData = getAllRow(that.productTableData, []);
          that.goodsTotal = Number(
            data.data.skillGoodsTimeResponseList[0].total
          );
          if(data.data.skillGoodsTimeResponseList[0].skuTotal>9999){
            that.noMutexProductLabel = "生效商品（9999+）";
          }else{
            that.noMutexProductLabel = "生效商品（"+data.data.skillGoodsTimeResponseList[0].skuTotal+"）";
          }
          that.skuTotal = Number(
            data.data.skillGoodsTimeResponseList[0].skuTotal
          );
        }else{
          that.noMutexProductLabel = "生效商品（0）";
        }
      });
    },
    /**
     * 保存店铺商家
     */
    relatedMerchant() {
      //查询时间段 默认选择第一个
      let that = this;
      this.utils.request.skillQueryTimeOfDate({ promotionId: this.skillId }, res => {
          if (res != null && res.data != null) {
            that.periodList = res.data.responseInfoList;
            that.timeOfDateId = res.data.responseInfoList[0].skillTimeId;
          }
          //保存完商家、店铺后清空本地商品信息，防止接口返回慢还展示商品信息
          this.productTableData = [];
          this.skillQueryGoods();
          this.getMutexProductList();
        }
      );
    },
    /**
     * 确认添加商品
     */
    addProductChange(val) {
      if (this.selectAddProduct.length < 1) {
        this.$message({ message: "请选择要添加的商品", type: "warning" });
        return false;
      }
      let tableData = this.productTableData.concat(this.mutexProductList);

      tableData.forEach(res => {
        this.selectAddProduct.forEach((item, index) => {
          //排除已保存过的商品
          if (res.goodsId == item.id) {
            this.selectAddProduct.splice(index, 1);
          }
        });
      });
      if (this.selectAddProduct && this.selectAddProduct.length > 0) {
        this.productTableData = this.productTableData.concat(
          this.selectAddProduct
        );
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
        this.relatedProducts();
      } else {
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
      }
    },
    selectPorduct(val) {
      this.productSelectFlag = val;
    },
    /**
     * 条数刷新
     */
    producthandleSizeChange(val) {},
    /**
     * 换页刷新
     */
    producthandleCurrentChange(val) {
      this.formInline.start = val;
      this.queryPageProductManagement();
    },
    /**
     * 选择商品
     */
    selectAddProductChange(val) {
      this.selectAddProduct = val;
    },
    /**
     * 批量删除商品
     */
    batchDeleteProduct() {

      let this_ = this;
      let ids = [];
      this.allProductData.forEach(function(item,index,array){
        //判断父下面是否全选
        if(item.mpParentId == '0' && item.isCheck){
          if(item.children && item.children.length > 0){
            let isCheckItems = item.children.filter(function (subItem, index) {
              return !subItem.isCheck;
            });
            if(!(isCheckItems && isCheckItems.length > 0)){
              ids.push(item.goodsId);
            }
          }else{
            ids.push(item.goodsId);
          }
        }else if(item.mpParentId != '0' && item.isCheck){
          ids.push(item.goodsId);
        }
      });
      if (ids.length < 1) {
        this.$message({ message: "请选择要删除的商品", type: "warning" });
        return false;
      }
      this.$confirm("确认批量删除已选内容？", "提示", {
        type: "warning"
      })
        .then(() => {
          ids.forEach(item => {
            this.utils.request.skillDeleteGoods(
              {
                goodsId: item,
                promotionId: this.skillId,
                timeId: this.timeOfDateId
              },
              res => {
                this.skillQueryGoods();
              }
            );
          });
          this.productSelectFlag = [];
        })
        .catch(() => {});
    },
    deleteProduct(index, row) {
      let proId = row.goodsId;
      this.utils.request.skillDeleteGoods(
        {
          goodsId: proId,
          promotionId: this.skillId,
          timeId: this.timeOfDateId
        },
        res => {
          this.skillQueryGoods();
        }
      );
    },
    /**
     * 弹窗选择店铺
     */
    addStoreChangeSelect(val) {
      this.addStoreSelect = val;
    },
    /**
     * 弹窗换页刷新
     */
    storehandleSizeChange(val) {
      this.storeDataForm.limit = val;
      this.queryPageStoreList();
    },
    /**
     * 弹窗翻页
     */
    storehandleCurrentChange(val) {
      this.storeDataForm.start = val;
      this.queryPageStoreList();
    },
    /**
     * 确认添加店铺
     */
    addStoreChange() {
      if (this.addStoreSelect.length < 1) {
        this.$message({ message: "请选择要添加的店铺", type: "warning" });
        return false;
      }
      this.storeTableData.forEach(res => {
        this.addStoreSelect.forEach((item, index) => {
          //排除已保存过的店铺
          if (res.id == item.id) {
            this.addStoreSelect.splice(index, 1);
          }
        });
      });
      if (this.addStoreSelect && this.addStoreSelect.length > 0) {
        let that = this;
        let paramData = [];
        this.addStoreSelect.forEach(item => {
          paramData.push({
            merchantId: item.id,
            storeName: item.storeName,
            storeId: item.id,
            storeCode: item.storeCode,
            merchantName:item.storeName,
            channelCode: ""
          });
        });
        let param = { promotionId: this.skillId, storeInfoList: paramData };
        this.utils.request.skillAddStore(param, res => {
          this.dialogVisibleStore = !this.dialogVisibleStore;
          this.addStoreSelect = [];
          this.skillQueryStore();
        });
      } else {
        this.dialogVisibleStore = !this.dialogVisibleStore;
      }
    },
    /**
        添加店铺
        */
    addStore() {
      if (this.tableData.length == 0) {
        this.$message({ message: "请先选择商家", type: "warning" });
        return false;
      }
      this.queryPageStoreList();
      this.dialogVisibleStore = true;
    },
    /**
     * 批量删除店铺
     */
    batchDeleteStore() {
      if (this.multipleStoreSelection.length < 1) {
        this.$message({ message: "请选择要删除的店铺", type: "warning" });
        return false;
      }
      this.$confirm("确认批量删除已选内容？", "提示", {
        type: "warning"
      })
        .then(() => {
          this.multipleStoreSelection.forEach(item => {
            this.utils.request.skillDeleteStore(
              { promotionId: this.skillId, storeId: item.id },
              res => {
                this.skillQueryStore();
              }
            );
          });
          this.multipleStoreSelection = [];
        })
        .catch(() => {});
    },
    /**
     * 选择店铺
     */
    selectStoreChange(val) {
      this.multipleStoreSelection = val;
    },
    /**
     * 删除店铺
     */
    handleDeleteStore(index, row) {
      // this.$confirm("确定删除吗？", "提示", {
      //   type: "warning"
      // }).then(() => {
        let proId = row.id;
        this.utils.request.skillDeleteStore(
          { promotionId: this.skillId, storeId: proId },
          res => {
            this.skillQueryStore();
          }
        );
      // })
    },

    /**
     * 新增商家选择
     */
    addMerchantChangeSelect(val) {
      this.addMerchantSelect = val;
    },
    /**
     * 添加商家
     */
    addMerchantChange() {
      if (this.addMerchantSelect.length < 1) {
        this.$message({ message: "请选择要添加的商家", type: "warning" });
        return false;
      }
      this.tableData.forEach(res => {
        this.addMerchantSelect.forEach((item, index) => {
          //排除已选择的商家
          if (res.merchantId == item.id) {
            this.addMerchantSelect.splice(index, 1);
          }
        });
      });
      if (this.addMerchantSelect && this.addMerchantSelect.length > 0) {
        this.tableData = this.tableData.concat(this.addMerchantSelect);
        let that = this;
        let paramData = [];
        this.addMerchantSelect.forEach(item => {
          paramData.push({
            orgNumber: item.orgNumber,
            merchantId: item.id,
            merchantName: item.name,
            merchantTypeId: item.merchantType,
            merchantTypeName:
              item.merchantType == "1" ? "自营商家" : "第三方商家",
            channelCode: ""
          });
        });
        let param = { promotionId: this.skillId, merchantInfoList: paramData };
        this.utils.request.skillAddMerchant(param, res => {
          this.dialogVisibleMerchant = !this.dialogVisibleMerchant;
          this.addMerchantSelect = [];
          this.skillQueryMerchant();
        });
      } else {
        this.dialogVisibleMerchant = !this.dialogVisibleMerchant;
      }
    },
    /**
     * 商家列表换页刷薰
     *
     */
    merchanthandleSizeChange(val) {
      this.merchantDataForm.limit = val;
      this.queryPageMerchantList();
    },
    merchanthandleCurrentChange(val) {
      this.merchantDataForm.start = val;
      this.queryPageMerchantList();
    },
    uploadMethod(val) {
      let this_=this;
      let param = new FormData();
      let  url= this.utils.imgUploadUrl;
      //通过append向form对象添加数据
      param.append("file", val.file);
      //FormData私有类对象，访问不到，可以通过get判断值是否传进去
      let config = {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        }
      };
      axios.post(url, param, config).then(res => {
        this_.imgUrlList.push({ url: res.data.data.imageUrl, hover: null });
        this_.uploadMethodVisible = false;
        this_.$message({ message: "上传成功", type: "success" });
      });
    },
    /**
     * 批量删除商家
     */
    batchDeleteMerchant() {
      if (this.multipleMerchantSelection.length < 1) {
        this.$message({ message: "请选择要删除的商家", type: "warning" });
        return false;
      }
      this.$confirm("确认批量删除已选内容？", "提示", {
        type: "warning"
      })
        .then(() => {
          this.multipleMerchantSelection.forEach(item => {
            // for(let index = 0 ; index < this.tableData.length ; index++){
            //     if(this.tableData[index].id == item.id){
            //         this.tableData.splice(index,1);
            //     }
            // }
            this.utils.request.skillDeleteMerchant(
              { merchantId: item.merchantId, promotionId: this.skillId },
              res => {
                this.merchantStaticDataForm.start = 1;
                this.storeStaticDataForm.start = 1;
                this.skillQueryMerchant();
                this.skillQueryStore();
              }
            );
          });
          this.multipleMerchantSelection = [];
        })
        .catch(() => {});
    },
    /**
     * 多选商家
     */
    selectMerchantChange(val) {
      this.multipleMerchantSelection = val;
    },
    /**
     * 渠道选择
     */
    channelCheckChange(data, checked, indeterminate) {
      let index = this.dataForm.channelIds.indexOf(data.id);
      if (index != -1) {
        //存在
        this.dataForm.channelIds.splice(index, 1);
      } else {
        //不存在
        this.dataForm.channelIds.push(data.id);
      }

      this.channelChange();
    },
    /**
     * delete图片列表
     */
    deleteimgUrlList(index) {
      this.imgUrlList.splice(index, 1);
    },
    /**
     * 素材列表条数
     */
    handleSizeChange(val) {
      this.materialQueryPageFilters.limit = val;
      this.handleNodeClick(undefined);
    },
    /**
     * 换页
     */
    handleCurrentChange(val) {
      this.materialQueryPageFilters.start = val;
      this.handleNodeClick(undefined);
    },
    /**
     *选择素材
     */
    selectMaterial(index) {
      if (this.materialList[index].isSelect == undefined) {
        this.materialList[index].isSelect = false;
      }
      if (this.materialList[index].isSelect) {
        this.materialImgNumber--;
      } else {
        this.materialImgNumber++;
      }
      this.materialList[index].isSelect = !this.materialList[index].isSelect;
    },
    /**
     * 素材确认
     */
    addMaterial() {
      let flag = true;
      this.materialList.forEach(item => {
        if (item.isSelect) {
          flag = false;
          this.imgUrlList.push({ url: item.materialUrl, hover: null });
        }
      });
      if (flag) {
        this.$message({ message: "请选择要选用素材", type: "warning" });
        return false;
      }
      this.materialLibraryVisible = false;
      this.uploadMethodVisible = false;
      this.$message({ message: "选用成功", type: "success" });
    },
    /**
     * 菜单树选项卡
     */
    handleNodeClick(data) {
      if (data != undefined && data.id != null) {
        this.materialQueryPageFilters.materialName = null;
      }
      this.materialTitle =
        data != undefined && data.categoryName != null
          ? data.categoryName
          : this.materialTitle;
      this.materialQueryPageFilters.categoryId =
        data != undefined && data.id != null
          ? data.id
          : this.materialQueryPageFilters.categoryId;
      this.materialQueryPageFilters.materialName =
        this.materialQueryPageFilters.materialName == ""
          ? null
          : this.materialQueryPageFilters.materialName;
      this.utils.request.materialQueryPage(
        this.materialQueryPageFilters,
        res => {
          res.data.rows.forEach(item => {
            item.isSelect = false;
          });
          this.materialList = res.data.rows;
          this.materialListTotal = res.data.total;
        }
      );
    },
    /**
     * 菜单树选项卡
     */
    handleClick(val) {},
    /**
     * 查询素材树
     */
    materialQueryTree() {
      let that = this;
      this.utils.request.materialQueryTree({}, res => {
        this.deptTreeList = res.data.deptTreeList;
        this.localTreeList = res.data.localTreeList;
      });
    },
    /**
     * 本地上传图片成功回调
     */
    imgUploadSuccess(response, file, fileList) {
      //
      this.imgUrlList.push({ url: URL.createObjectURL(file.raw), hover: null });
      this.uploadMethodVisible = false;
    },
    imgUploadError(err, file, fileList) {
      this.$message({ message: "文件上传失败,请重新上传", type: "error" });
    },
    /**
     * 选择上传方式弹窗
     */
    selectUploadMethod() {
      this.uploadMethodVisible = true;
    },
    /**
     * 鼠标移入
     */
    mouseEnter(index) {
      //
      this.imgUrlList[index].hover = true;
    },
    /**
     * 鼠标移出
     */
    mouseLeave(index) {
      //
      this.imgUrlList[index].hover = null;
    },
    /**
     * 新增标签弹窗
     */
    addtags() {
      if (this.$refs["addTagForm"] != undefined) {
        this.$refs["addTagForm"].resetFields();
      }
      this.addTagDialogFormVisible = true;
    },
    /**
     * 新增时间段
     */
    addTimeEveryDay() {
      if (!this.dataForm.startTimeEveryDay || !this.dataForm.endTimeEveryDay) {
        this.$message({
          message: "请填写完整最后一个时段后再新增时段",
          type: "error"
        });
        return false;
      }
      let flag = false;
      if (this.dataForm.TimeEveryDay.length > 0) {
        this.dataForm.TimeEveryDay.forEach(function(item, index) {
          if (
            item.startTimeOfDate == undefined ||
            item.endTimeOfDate == undefined
          ) {
            flag = true;
            return;
          }
        });
      }
      if (flag) {
        this.$message({
          message: "请填写完整最后一个时段后再新增时段",
          type: "error"
        });
        return false;
      }
      this.dataForm.TimeEveryDay.push({});
      if (this.dataForm.TimeEveryDay.length >= 11) {
        this.addTimeEveryDayBtnStatus = true;
        return false;
      }else{
        this.addTimeEveryDayBtnStatus = false;
        return true;
      }
    },
    /**
     * 删除时间段
     */
    deleteTimeEveryDay(index) {
      this.$confirm(
        "此操作会将该时间段内的选品一并删除，确定要删除该时间段吗？",
        "提示",
        {
          type: "warning"
        }
      )
        .then(() => {
          let timeEveryDay = this.dataForm.TimeEveryDay[index];

          if (timeEveryDay.skillTimeId != undefined) {
            //删除时间段
            this.utils.request.skillDeleteTimeOfDate(
              {
                promotionId: this.skillId,
                skillTimeId: timeEveryDay.skillTimeId
              },
              res => {}
            );
          }
          this.dataForm.TimeEveryDay.splice(index, 1);

          if(this.dataForm.TimeEveryDay.length < 12){
            this.addTimeEveryDayBtnStatus  = false;
          }
        })
        .catch(() => {});
    },
    /**
     * 格式化时间段
     */
    formatTimeEveryDay(date) {
      if (date == undefined) {
        return "";
      }
      //
      let dataList = date.split(":");
      let time = Number(dataList[0]) - 1 + "";
      let returnTime;
      if (time.length < 2) {
        returnTime = "0" + time + ":" + dataList[1];
      } else {
        returnTime = time + ":" + dataList[1];
      }
      return returnTime;
    },
    /**
     * 格式化活动时间
     */
    SeckillTimeChanage(e) {

      this.dataForm.startTime = formatDate(e[0], "yyyy-MM-dd hh:mm:ss");
      this.dataForm.endTime = formatDate(e[1], "yyyy-MM-dd hh:mm:ss");

      // let startTime = formatDate(e[0], "yyyy-MM-dd hh:mm:ss");
      // let startTimeArray = startTime.split(" ");
      // if (startTimeArray[1] == "00:00:00") {
      //   //
      //   startTime =
      //     startTimeArray[0] +
      //     " " +
      //     formatDate(new Date(), "yyyy-MM-dd hh:mm:ss").split(" ")[1];
      // }
      // let endTime = formatDate(e[1], "yyyy-MM-dd hh:mm:ss");
      // let endTimeArray = endTime.split(" ");
      // if (endTimeArray[1] == "00:00:00") {
      //   //
      //   endTime =
      //     endTimeArray[0] +
      //     " " +
      //     formatDate(new Date(), "yyyy-MM-dd hh:mm:ss").split(" ")[1];
      // }
      // //
      // this.dataForm.startTime = startTime;
      // this.dataForm.endTime = endTime;
      // let startYearDate = startTime.split("-");
      // let startTimeDate = startTime.split(":");

      // let endYearDate = endTime.split("-");
      // let endTimeDate = endTime.split(":");
      // //
      // this.dataForm.SeckillTime = [
      //   new Date(
      //     startYearDate[0],
      //     startYearDate[1],
      //     startYearDate[2].split(" ")[0],
      //     startTimeDate[0].split(" ")[1],
      //     startTimeDate[1],
      //     startTimeDate[2]
      //   ),
      //   new Date(
      //     endYearDate[0],
      //     endYearDate[1],
      //     endYearDate[2].split(" ")[0],
      //     endTimeDate[0].split(" ")[1],
      //     endTimeDate[1],
      //     endTimeDate[2]
      //   )
      // ];
    },
    select(row) {
      let flag = true;
      this.tableData.forEach(res => {
        if (res.id == row.id) {
          this.$message({ message: "不能添加重复商品", type: "error" });
          flag = false;
        }
      });
      if (flag) {
        this.tableData.push(row);
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
      }
    },
    handleChange(myArray) {},
    add() {
      this.queryPageProductManagement();
      this.dialogVisibleTwo = true;
    },
    /**
     * 添加商家按钮
     */
    addMerchant() {
      // this.queryPageProductManagement();
      this.queryPageMerchantList();
      this.dialogVisibleMerchant = true;
    },
    queryPageMerchantList() {
      let that = this;
      this.productListloading = true;
      //只有运营平台有使用渠道
      if (this.deptType == 0) {
        this.merchantDataForm.childIds = that.dataForm.channelIds;
      }
      this.utils.request.queryMerchantList(this.merchantDataForm, res => {
        that.productListloading = false;
        if (res.code == "0000") {
          that.merchantTableData = res.data.rows;
          that.merchantListTotal = res.data.total;
        }
      });
    },
    queryPageStoreList() {
      this.utils.request.couponGetMerchantIdsByPromotionId(
        { promotionId: this.skillId , generalPromotion: true},
        data => {
          if (data.data.length == 0) {
            this.$message({ message: "请先选择商家", type: "warning" });
            return false;
          }
          let this_ = this;
          this.storeDataForm.merchantIds = data.data.join(",");
          this.utils.request.queryByIds(this.storeDataForm, function(res) {
            this_.productListloading = false;
            if (res.code == "0000") {
              if(res.data.rows == null || res.data.rows.length < 1){
                // this.$message({"type":"warning","message":"查询暂无数据，请输入正确的查询条件"})
                this_.storeAddTableData = [];
                this_.storeListTotal = 0;
              }else{
                this_.storeAddTableData = res.data.rows;
                this_.storeListTotal = res.total;
              }
            }
          });
        }
      );
    },
    //table的双色条纹
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return "warning-row";
      } else if (rowIndex === 3) {
        return "success-row";
      }
      return "";
    },
    //修改table header的背景色
    tableHeaderColor({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background-color:rgb(250,250,250);";
      }
    },

    handleDelete(index, row) {
      let proId = row.merchantId;

      //删除商家
      this.utils.request.skillDeleteMerchant(
        { merchantId: proId, promotionId: this.skillId },
        res => {
          this.merchantStaticDataForm.start = 1;
          this.storeStaticDataForm.start = 1;
          this.skillQueryMerchant();
          this.skillQueryStore();
        }
      );
    },

    next() {
      if (this.active == 1) {
        //提交订单
        this.submitCouponInfo("dataForm");
      }
        // else if (this.active == 2) {
      //   //关联商家店铺
      //   if (this.tableData.length == 0) {
      //     // this.$message({ message: "请添加商家", type: "fail" });
      //     // return;
      //   }
      //   if(this.storeTableData.length == 0){
      //     // this.$message({ message: "请添加店铺", type: "fail" });
      //     // return;
      //   }
      //   this.relatedMerchant();
      //   this.addActive();
      // }
      else if (this.active == 2) {
        this.skillQueryGoods();
        //关联商品
        if (this.productTableData.length == 0) {
          // this.$message({ message: "请添加商品", type: "fail" });
          // return;
        }
        let flag = true;
        this.productTableData.forEach(product=>{
          // if(!this.checkProductLimits(product)){
          //   flag = false;
          //   return;
          // }
          /*product.children.forEach(childrenProduct=>{
            if(!this.checkProductLimits(childrenProduct)){
              flag = false;
              throw new Error("请输入必填项");
            }
          })*/
            if(!this.checkProductLimits(product)){
            flag = false;
            throw new Error("请输入必填项");
          }
        })
        if(!flag){
          this.$message({ message: "请输入必填项", type: "error" });
          return false;
        }
        this.utils.request.skillCheckSkill(
          { promotionId: this.skillId, updateStatus: "1" },
          res => {
            this.$set(this.dataForm,"status",11);
          }
        );
        this.addActive();
      }

    },
    addActive() {
      this.active = parseInt(this.active)  + 1;
      this.$router.push({ params: { promotionId: this.skillId,auth:0,active:this.active} })
      if (this.active > 4) {
        this.$router.push({
          path: "/pages/promotionManagement/seckillPromotion"
        });
      }
    },
    //上一步
    back() {
      this.active = parseInt(this.active) - 1;
      this.$router.push({ params: { promotionId: this.skillId,auth:0,active:this.active} })
      this.nextOrBack();
    },

    viewList() {
      this.$router.push({
        path: "/pages/promotionManagement/seckillPromotion"
      });
    },
    shenheHuodong(flag) {
      if (flag == 0) {
        //提交审核
        let that = this;
        this.$confirm("确认提交审核？", "提示", {
          type: "warning",
          closeOnClickModal: false,
        }).then(() => {
          this.utils.request.skillCheckSkill(
            { promotionId: this.skillId, updateStatus: "2" },
            res => {
              that.shenhe = 1;
              that.$message({ message: "提交审核成功", type: "success" });
              that.getSkillDetail();
            }
          );
        })
      } else {
        //审核
        this.dialogFormVisible = true;
        this.form.checkRemark = "";
        this.$nextTick(() => {
          this.$refs['form'].clearValidate();
        });
      }
      // this.$message({ message: "操作成功", type: "success" });
    },
    dateFilter: function(input) {
      var d = new Date(input);
      var year = d.getFullYear();
      var month =
        d.getMonth() < 9 ? "0" + (d.getMonth() + 1) : "" + (d.getMonth() + 1);
      var day = d.getDate() < 10 ? "0" + d.getDate() : "" + d.getDate();
      var hour = d.getHours() < 10 ? "0" + d.getHours() : "" + d.getHours();
      var minutes =
        d.getMinutes() < 10 ? "0" + d.getMinutes() : "" + d.getMinutes();
      var seconds =
        d.getSeconds() < 10 ? "0" + d.getSeconds() : "" + d.getSeconds();
      return (
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        ":" +
        minutes +
        ":" +
        seconds
      );
    },
    /* 提交优惠券信息 */
    submitCouponInfo(formName) {
      //  this.active = this.active + 1;
      this.$refs[formName].validate(valid => {
        if (valid) {
          // const loading = this.$loading({
          //   lock: true,
          //   text: "小的正在努力加载中......",
          //   spinner: "el-icon-loading",
          //   background: "rgba(0, 0, 0, 0.8)"
          // });
          // this.dataForm.channelCodes = this.dataForm.channelIds;
          this.dataForm.imagesUrls = this.imgUrlList.map(item => item.url);
          //如分摊则校验分摊比例总和不能超过100
          // if (this.dataForm.costAllocationFlag == "1" && this.deptType != 3) {
          //   if (
          //     Number(this.dataForm.parentAllocationScale || 0) +
          //       Number(this.dataForm.childAllocationScale || 0) +
          //       Number(this.dataForm.merchantAllocationScale || 0) +
          //       Number(this.dataForm.storeAllocationScale || 0) !=
          //     100
          //   ) {
          //     this.$message({ message: "分摊比例总和为100", type: "warning" });
          //     // loading.close();
          //     return false;
          //   }
          // }

          //如果是店铺 自己分摊100
          // if(this.deptType == 3){
          //   this.dataForm.costAllocationFlag = "1"
          //   this.dataForm.storeAllocationScale = 100;
          // }

          //使用渠道
          //当前登录用户身份为母平台校验所属渠道
          if (this.deptType == 0) {
            /*if (this.$refs.channelTree.getCheckedKeys().length <= 0) {
              this.$message({ message: "请选择使用渠道", type: "warning" });
              // loading.close();
              return false;
            } else {
              this.dataForm.channelCodes = this.$refs.channelTree
                .getCheckedKeys()
                .join(",");
            }*/
          } else {
            //非母平台清除子平台编码
            if (this.dataForm.channelCodes) {
              delete this.dataForm.channelCodes;
            }
          }

          this.dataForm.proUserType = this.selectUserType.join(",");
          this.dataForm.memTypes = this.selectMemTypes.join(",");
          this.dataForm.channelId = this.channelId.join(",");


          if (this.skillId != "0") {
            let that_ = this;
            that_.dataForm.updateTimeInfoList = [
              {
                startTimeOfDate: that_.dataForm.startTimeEveryDay,
                endTimeOfDate: that_.dataForm.endTimeEveryDay,
                skillTimeId: that_.responseInfoList[0].skillTimeId
              }
            ];
            let noUpdateTimeList = [];
            this.dataForm.timeInfoList =
              this.dataForm.TimeEveryDay == null
                ? []
                : this.dataForm.TimeEveryDay;
            this.dataForm.timeInfoList.forEach(item => {
              if (item.skillTimeId != undefined) {
                this.dataForm.updateTimeInfoList.push(item);
              } else {
                noUpdateTimeList.push(item);
              }
            });

            this.dataForm.timeInfoList = noUpdateTimeList;
            this.dataForm.promotionId = this.skillId;
            //修改
            let that = this;
            this.utils.request.skillUpdateConfig(this.dataForm, res => {
              // loading.close();
              if (res.code == "0000") {
                // that.skillId = res.data;
                that.addActive();
                that.relatedMerchant();
                // that.skillQueryMerchant();
                // that.skillQueryStore();
              } else {
                that.$message({
                  message: res.msg || "修改秒杀活动失败,请重试",
                  type: "error"
                });
              }
            });
          } else {
            this.dataForm.timeInfoList = [
              {
                startTimeOfDate: this.dataForm.startTimeEveryDay,
                endTimeOfDate: this.dataForm.endTimeEveryDay
              }
            ];
            if (this.dataForm.TimeEveryDay == undefined) {
              this.dataForm.TimeEveryDay = [];
            }
            this.dataForm.timeInfoList = this.dataForm.timeInfoList.concat(
              this.dataForm.TimeEveryDay
            );
            let that = this;
            this.utils.request.skillAddConfig(this.dataForm, res => {
              // loading.close();
              if (res.code == "0000") {
                that.skillId = res.data;
                that.addActive();
                that.relatedMerchant();
                // that.skillQueryMerchant();
                // that.skillQueryStore();
              } else {
                that.$message({
                  message: res.msg || "修改秒杀活动失败,请重试",
                  type: "error"
                });
              }
            });
          }
        } else {
          return false;
        }
      });
    },
    restForm() {
      this.formInline.code = "";
      this.formInline.chineseName = "";
      this.formInline.goodsCategory = "";
      this.formInline.goodsName = "";
      this.formInline.thirdSpuId = "";
      this.formInline.start = 1;
      this.queryPageProductManagement();
    },
    queryPageProductManagement() {
      let that = this;
      this.productListloading = true;
      this.formInline.goodsCategory =
        this.formInline.goodsCategory == ""
          ? null
          : this.formInline.goodsCategory;
      this.formInline.goodsName =
        this.formInline.goodsName == "" ? null : this.formInline.goodsName;
      // this.formInline.storeIds = this.storeTableData.map(item=>item.storeId);
      this.utils.request.couponGetStoreIdsByPromotionId(
        { promotionId: this.skillId },
        data => {
          if (data.data == null && data.data.length < 1) {
            this.$message({ message: "请选择店铺", type: "error" });
            return false;
          }
          this.formInline.storeIds = data.data;
          this.utils.request.promotionSpuPageByPromotionId(
            this.formInline,
            res => {
              that.productListloading = false;
              if (res.code == "0000") {
                // that.tableDataTwo = res.data.rows;
                that.tableDataTwo = res.data.rows.map((ele, index) => {
                let spu = {};
                spu.id = ele.id;
                spu.thirdSpuId = ele.code;
                spu.goodsName = ele.chineseName;
                spu.totalStock = ele.totalStock;
                spu.goodsCategory = ele.fullNamePath;
                spu.merchantName = ele.merchantName;
                spu.storeName = ele.storeName;
                spu.salePriceScope = ele.salePriceWithTax;
                // spu.measureUnit = ele.measureUnit;
                return spu;
              });

                that.productListTotal = Number(res.data.total);
              }
            }
          );
        }
      );
    },
    /* 关联商品 */
    relatedProducts() {
      if (this.productTableData.length < 1) {
        // this.$message({ message: "所关联的商品不能为空", type: "warning" });
        // return false;
      }
      let that = this;
      let param = this.selectAddProduct.map(item => item.id);
      this.utils.request.skillAddGoods(
        {
          promotionId: this.skillId,
          goodsInfoList: param,
          skillTimeId: this.timeOfDateId
        },
        res => {
          // loading.close();
          if (res != null && res.data != null && res.code == "0000") {
            //商品新增成功
            this.selectAddProduct = [];

            that.skillQueryGoods();
            that.getMutexProductList();
          }else if(res.code == "5000"){
            that.skillQueryGoods();
            that.getMutexProductList();
            that.$message({ message: res.msg, type: "error" });
          }
        }
      );
    },
    reviewDialog: function(data) {
      let that = this;
      this.form.promotionId = this.skillId;
      this.form.updateStatus = data;
      that.utils.request.skillCheckSkill(this.form, res => {
        if (res.code == "0000") {
          that.dialogFormVisible = false;
          that.$message({ message: "审核完成", type: "success" });
          that.shenhe = 2;
        } else {
          that.$message({ message: "审核失败", type: "error" });
        }
        that.getSkillDetail();
      });
    },
    reviewDialogNo: function(data) {
      let that = this;
      this.form.promotionId = this.skillId;
      this.form.updateStatus = data;
      this.$refs.form.validate((valid) => {
        if (valid) {
          that.utils.request.skillCheckSkill(this.form, res => {
            if (res.code == "0000") {
              that.dialogFormVisible = false;
              that.$message({ message: "审核完成", type: "success" });
              that.shenhe = 2;
            } else {
              that.$message({ message: "审核失败", type: "error" });
            }
            that.getSkillDetail();
          });
        }
      });
    },
    //获取子平台列表
    getChildList() {
      let channel = { childName: "卡奥斯运营平台", id: "179" ,deptId: "179"};
      let that = this;
      this.utils.request.queryChildList({}, res => {
        if (res.code == "0000" && res.data && res.data.length > 0) {
          channel.children = res.data;
          that.channelList.push(channel);
          that.defaultChecked(channel);

          that.$nextTick(()=>{
            this.channelChange();
          })
        }
      });
    },
    defaultChecked(channel) {
      //判断是否是修改 如果是修改 不默认选中全部

      if (this.skillId == null || this.skillId == "0") {
        let ids = this.channelList[0].children.map(item => item.id);
        ids.push(channel.id + "");
        this.$set(this.dataForm, "channelCodes", ids);
        this.$set(this.dataForm, "channelIds", ids);
/*        this.$nextTick(() => {
          this.$refs.channelTree.setCheckedKeys(ids);
        });*/
      }
    },

    checkProductLimitsIsNull(row){
      if(row.skillPrice == null || row.skillPrice == '' || row.storeChannelLimit == null || row.storeChannelLimit == ''
          || row.userChannelLimit == null || row.userChannelLimit == '' ){
        return false;
      }
      return true;
    },


    //检验商品
    checkProductLimits(row){
        var reg = /^(?!0(\.0{1,2})?$)(\d(\.\d{1,2})?|10)$/;//0-10
        var priceReg = /^\d+\.?\d{0,2}$/; // 2位小数
        var regPos = /^[1-9]([0-9]*)$/; // 非负整数
          // row.frontMoney //定金
          // row.frontMoneyDeductAmount //定金抵扣金
        if(!row.skillPrice){
          this.$message({ message: "请输入商品秒杀价", type: "error" });
          return false;
        }
        if(!priceReg.test(row.skillPrice)){
          this.$message({ message: "秒杀价为正数，支持输入2位小数", type: "error" });
          return false;
        }
        if(row.storeChannelLimit && !regPos.test(row.storeChannelLimit)){
          this.$message({ message: "店铺限购只能输入正整数", type: "error" });
          return false;
        }
        if(row.userChannelLimit && !regPos.test(row.userChannelLimit)){
          this.$message({ message: "个人限购只能输入正整数", type: "error" });
          return false;
        }
        if(Number(row.storeChannelLimit) > Number(row.reserveNum)){
          this.$message({ message: "店铺限购需小于等于店铺库存", type: "error" });
          return false;
        }
        if(Number(row.userChannelLimit) > Number(row.storeChannelLimit)){
          this.$message({ message: "个人限购需小于于等于店铺限购", type: "error" });
          return false;
        }
        return true;
    },


    /**
     * 查询互斥商品
     */
    getMutexProductList(index) {
      var this_ = this;
      this.timeOfDateId = index != null ? this.periodList[index].skillTimeId : this.timeOfDateId;
      this.mutexProductForm.skillTimeId = this.timeOfDateId;
      this.mutexProductForm.promotionId = this.skillId;
      this.utils.request.skillQueryGoods(this.mutexProductForm, res => {
        if (res.code == "0000") {
          this_.mutexProductList = res.data.skillGoodsTimeResponseList[0].goodsInfoList;
          this_.isAllChecked = false;
          this_.isIndeterminateCheck = false;
          this_.allData = getAllRow(this_.mutexProductList, []);
          this_.mutexProductTotal = Number(res.data.skillGoodsTimeResponseList[0].total);
          if(res.data.skillGoodsTimeResponseList[0].skuTotal>9999){
            this_.mutexProductLabel = "互斥商品（9999+）";
          }else{
            this_.mutexProductLabel = "互斥商品（"+res.data.skillGoodsTimeResponseList[0].skuTotal+"）";
          }
        }else{
            this_.mutexProductLabel = "互斥商品（0）";
        }
      });
    },
    /**
     * 每页条数改变触发
     */
    handleSizeChangeMutexProductList(val){
      this.mutexProductForm.limit = val;
      this.mutexProductForm.start = 1;
      this.getMutexProductList();
    },
    /**
     * 换页刷新
     */
    handleCurrentChangeMutexProductList(val){
      this.merchantProductSearchForm.start = val;
      this.getMutexProductList();
    },

    /**
     * 互斥商品重新添加
     */
    renewAdd(row){
      let that = this;
      let param = {};
      var productIdList = [];
      param.promotionId = this.skillId;
      param.promotionType = 1;
      if(row.typeOfProduct == '10'){
          //spu
          row.children.forEach(item=>{
              productIdList.push(item.id);
          })
      }else if(row.typeOfProduct == '20'){
          productIdList.push(row.id);
      }
      param.productIdList = productIdList;
      this.utils.request.renewAddMutexProduct(param,res=>{
        if(res.code=='0000'){
          that.getMutexProductList();
          that.skillQueryGoods();
          let data = res.data;
          if(data.businessCode == '0001'){
            that.$message({message: data.businessMsg, type: "success"});
          }else if(data.businessCode == '0002'){
            that.$message({message:data.businessMsg, type: "error"})
          }else if(data.businessCode == '0003'){
            that.$alert(data.businessMsg, '提示', {
              confirmButtonText: '知道了',
              callback: action => {}
            });
          }
        }
      });
    },

    /**
     * 批量重新添加选择数据
     */
    batchRenewAddSelectionChange(val) {
      this.batchRenewAddSelection = val;
    },

    /**
     * 批量重新添加
     */
    batchRenewAdd(){
      let that = this;
        let param = {};
        var productIdList = [];
        param.promotionId = this.skillId;
        param.promotionType = 1;
        this.allData.forEach(function(item,index,array){
          if(item.mpParentId != '0' && item.isCheck){
            productIdList.push(item.id);
          }
        });
        if(productIdList.length < 1){
          this.$message({ message: "未选择重新添加条目", type: "error" });
          return false;
        }
        param.productIdList = productIdList;
        this.utils.request.renewAddMutexProduct(param,res=>{
          if(res.code=='0000'){
            that.getMutexProductList();
            that.skillQueryGoods();
            let data = res.data;
            if(data.businessCode == '0001'){
              this.$message({message: data.businessMsg, type: "success"});
            }else if(data.businessCode == '0002'){
              this.$message({message:data.businessMsg, type: "error"})
            }else if(data.businessCode == '0003'){
              this.$alert(data.businessMsg, '提示', {
                confirmButtonText: '知道了',
                callback: action => {}
              });
            }
          }
        });
    },
    /**
     * 生效商品 互斥商品tab选中触发
     */
    productTabs(tab){
      if(tab.index==0){
        this.showButtons = true;
      }else{
        this.showButtons = false;
      }
    },
    /**
     * 互斥商品查看详情
     */
    getMutexInfo(row){
      let that = this;
      this.mutexPromotionForm.promotionMerchantProductId = row.id;
      this.getPromotionMutexListByProductId();
    },
    getPromotionMutexListByProductId(){
      let that = this;
      this.utils.request.getPromotionMutexListByProductId(this.mutexPromotionForm,res=>{
        if(res.code=='0000'){
            that.mutexPromotionList = res.data.rows;
            that.mutexPromotionListTotal = res.data.total;
            that.mutexPromotionVisible = true;
        }
      });
    },

    /**
     * 每页条数改变触发
     */
    mutexPromotionListSizeChange(val){

      this.mutexPromotionForm.limit = val;
      this.mutexPromotionForm.start = 1;
      this.getPromotionMutexListByProductId();
    },
    /**
     * 换页刷新
     */
    mutexPromotionListCurrentChange(val){

      this.mutexPromotionForm.start = val;
      this.getPromotionMutexListByProductId();
    },
    /**
     * 点击活动名称跳转详情
     */
    linkInfoByMutexProduct(promotionId,type){
      if(type == 1){
        this.$router.push({ path: "/SinglePromotionDetail/" + promotionId + "/0"});
        //this.$router.push(`/SinglePromotionDetail?id=${promotionId}&auth=0`);
      }else if(type == 2){
        this.$router.push(`/FullNumPromotionDetailNew?id=${promotionId}&auth=0`);
      }else if(type == 3){
        this.$router.push({ path: "/FullPromotionDetailNew/" + promotionId + "/0"});
        //this.$router.push(`/FullPromotionDetailNew?id=${promotionId}&auth=0`);
      }else if(type == 4){
        this.$router.push(`/SeckillDetail?promotionId=${promotionId}`);
      }else if(type == 5){
        this.$router.push({ path: "/GiftPromotionDetail/" + promotionId + "/0"});
        //this.$router.push(`/GiftPromotionDetail?id=${promotionId}&auth=0`);
      }else if(type == 6){
        this.$router.push({ path: "/ComplexPromotionInfo/" + promotionId});
      }else if(type == 7){
        this.$router.push({ path: "/XofferPromotionDetail/" + promotionId + "/0"});
        //this.$router.push(`/XofferPromotionDetail?id=${promotionId}&auth=0`);
      }else if(type == 8){
        this.$router.push({ path: "/IncreasePromotionDetail/" + promotionId + "/0"});
        //this.$router.push(`/IncreasePromotionDetail?id=${promotionId}&auth=0`);
      }else if(type == 9){
        this.$router.push(`/QueryPresellPromotion?value=${promotionId}&auth=0`);
      }else if(type == 10){
        this.$router.push("/GroupDetailPromotion?id=" + `${promotionId}`);
      }else if(type == 12){
        this.$router.push(`/QueryPromotion?value=${promotionId}&auth=0`);
      }
    },
    nextOrBack(){
      //根据当前url中active参数判断执行第几步方法
      if (this.active){
        if(parseInt(this.active) == 1){
           this.$nextTick(() =>{
             this.getSkillDetail();
           })
        }
        if (parseInt(this.active) == 2){
          this.$nextTick(() =>{
            this.skillQueryGoods();

          })
        }
      }
    },
    handleCheckedAllChange(value) {
      ////
      this.isIndeterminateCheck = false;

      this.allData.forEach(f => {
        f.isCheck = value;
        f.isIndeterminateCheck = false;
      });
    },
    handleCheckedChange(row, checked) {
      ////
      if (row.isIndeterminateCheck) {
        row.isCheck = true;
        checked = true;
      }
      row.isIndeterminateCheck = false;

      changeChild(row, checked);
      changeParent(row, this.allData);

      this.isAllChecked = this.allData.every(e => {
        return e.isCheck;
      });

      this.isIndeterminateCheck =
        !this.isAllChecked &&
        this.allData.some(e => {
          return e.isCheck;
        });
    },

    handleCheckedAllProductChange(value) {
      ////
      this.isIndeterminateProductCheck = false;

      this.allProductData.forEach(f => {
        f.isCheck = value;
        f.isIndeterminateCheck = false;
      });
    },
    handleCheckedProductChange(row, checked) {
      ////
      if (row.isIndeterminateCheck) {
        row.isCheck = true;
        checked = true;
      }
      row.isIndeterminateCheck = false;

      changeChild(row, checked);
      changeParent(row, this.allProductData);

      this.isAllProductChecked = this.allProductData.every(e => {
        return e.isCheck;
      });

      this.isIndeterminateProductCheck =
        !this.isAllProductChecked &&
        this.allProductData.some(e => {
          return e.isCheck;
        });
    },
  },
  created: function() {
    this.skillId = this.$route.params.promotionId;
    if (typeof this.$route.params.active != "undefined") {
      this.active = this.$route.params.active;
    }
  },
  mounted() {
    this.active = this.$route.params.active;
    this.skillId = this.$route.params.promotionId;
    this.materialQueryTree();
    if (typeof this.$route.params.promotionId != "undefined" && parseInt(this.$route.params.promotionId) >0) {
      this.getSkillDetail();
    }
    // this.getMemberList();
    //根据当前url中active参数判断执行第几步方法
    this.nextOrBack();
  },
  watch: {}
};
</script>

<style scoped lang="scss">
@import '../../../assets/css/public.scss';
/deep/ .is-bordered{
  padding: 12px 20px 12px 10px;
}
.mleft10 {
  margin-right: 10px;
}
/deep/ .tipsInfo{
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #ffbf5e;
    color: #fff;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
}
.material-main {
  width: 99%;
  background: #fff;
  // -webkit-box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04);
  // box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04);
  position: relative;
}
.material-header {
  display: flex;
  justify-content: space-between;
}
.material-title-right {
  // margin-top: 20px;
  // margin-right: 30px;
  /deep/ .el-input {
    width: 274px;
  }
  /deep/ .el-input__icon {
    line-height: 32px;
  }
  /deep/ .el-button {
    display: block;
    float: right;
    margin-left: 20px;
  }
}
.material-title-left {
  // margin-top: 20px;
  margin-left: 20px;
  font-size: 16px;
  color: #409eff;
  display: inline-block;
  height: 32px;
  line-height: 32px;
}
.material-main-list {
  display: flex;
  flex-wrap: wrap;
  margin-top: 20px;

  .material-main-item {
    position: relative;
    margin-left: 17px;
    padding: 10px;
    margin-bottom: 20px;
    background-color: #f0f0f0;
    border-radius: 4px;
    // box-sizing: border-box;
    overflow: hidden;
    cursor: pointer;
    .material-main-item-delete {
      position: absolute;
      top: 15px;
      right: 15px;
      z-index: 999;
      span {
        color: #fff;
      }
    }
  }
}
.material-main-item-img {
  width: 110px;
  height: 110px;
}
.material-main-item-name {
  width: 60%;
  margin-top: 6px;
  color: #909399;
  float: left;
  /deep/ .el-input {
    width: 80px;
    /deep/ .el-input__inner {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      height: 25px !important;
    }
  }
}
.editText {
  display: block;
  width: auto;
  height: 25px;
  line-height: 32px;
  margin-top: 5px;
  float: right;
}
.material-main-item-select {
  border: 1px solid #409eff;
}
.font12 {
  font-size: 12px;
}
.uploader {
  float: left;
  margin: 20px 0 0 20px;
}
// }

.tab-container-dialog {
  /deep/ .el-tabs__item {
    width: 102px !important;
  }
  /deep/ .el-tabs__item {
    border: none !important;
    border-bottom: 1px solid rgba(216, 216, 216, 1) !important;
    color: #909399 !important;
    &.is-active {
      color: #fff !important;
      background-color: #409eff;
    }
  }
  /deep/ .el-tabs__item.is-active::after {
    width: 0 !important;
  }
  // /deep/ .el-tabs__item:last-child{

  // }
  /deep/ .el-tabs {
    border: 1px solid rgba(216, 216, 216, 1);
    /deep/ .el-tab-pane {
      padding: 40px 0 60px 23px;
    }
    /deep/ .el-tabs__nav-wrap {
      padding: 0;
      // border: none;
    }
  }
}
.pagination {
  margin-top: 60px;
}
.m_l5 {
  margin-left: 5px;
}
.mb10 {
  margin-bottom: 10px;
}
.img-card {
  width: 140px;
  height: 140px;
  margin: 10px 0 10px 10px;
  position: relative;
  .deleteButton {
    position: absolute;
    right: 10px;
    bottom: 10px;
    cursor: pointer;
  }
}
.img-border {
  width: 775px;
  border: 1px solid rgb(162, 162, 162);
  height: 300px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
}
.activityDesc{
  margin-bottom: 0 !important;
}
.vt{
  /deep/ .el-form-item__content{
    vertical-align: top !important;
  }
}


 .flexBox{
  display: flex;
  flex-wrap: nowrap;
  align-content: flex-start;
  .child-name{
    flex-shrink: 0;
  }
  .checkboxes{
    display: flex;

  }

}
.pdl32{
  padding-left: 32px;
}
.pdl75{
  padding-left: 75px;
}

.w126{
  width: 126px;
}
.oe{
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
.width100{
  width: 97px;
}
.w104{
  width: 104px;
}
.ml60{
  margin-left: 60px;
}
.pdl30{
  padding-left: 30px;
}
.pdt20{
  padding-top: 20px;
}
.marginZero{
  /deep/ .el-form-item__content{
    margin-right: 0 !important;
  }
}
.w144{
  width: 144px !important;
}
.width450{
  width: 450px !important;
  /deep/ .el-input__inner{
    width: 450px !important;
  }
}
.etAlignment{
  /deep/ .el-form-item__content{
    .el-form-item__error{
      position: absolute !important;
      top: 100% !important;
    }
  }
}
.everyDate{
  .boxes:last-child{
    margin-bottom:0 !important
    }
}
</style>
